mail-archives/mono-list/2003-October/016679.html

103 строки
3.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-list] Determining the platform at compile and run time
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:jonpryor%40vt.edu">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="016667.html">
<LINK REL="Next" HREF="016668.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-list] Determining the platform at compile and run time
</H1>
<B>Jonathan Pryor
</B>
<A HREF="mailto:jonpryor%40vt.edu"
TITLE="[Mono-list] Determining the platform at compile and run time">jonpryor@vt.edu
</A><BR>
<I>Fri, 31 Oct 2003 07:07:03 -0500</I>
<P><UL>
<LI> Previous message: <A HREF="016667.html">[Mono-list] Determining the platform at compile and run time
</A></li>
<LI> Next message: <A HREF="016668.html">[Mono-list] Determining the platform at compile and run time
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16679">[ date ]</a>
<a href="thread.html#16679">[ thread ]</a>
<a href="subject.html#16679">[ subject ]</a>
<a href="author.html#16679">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Just to continue Fergus' line of reasoning, Type Reflector (CVS module:
type-reflector) does the same thing. It has three different front-ends
(Gtk#, System.Windows.Forms, and Console), that you can select by using
either a command-line argument (--displayer=NAME) or by setting an
option on the type-reflector.exe.config file.
Actually, the .config file supports an ordering of preferred front-ends,
so that it will try each one, in order, until it finds one that works.
- Jon
On Thu, 2003-10-30 at 22:44, Fergus Henderson wrote:
&gt;<i> On 31-Oct-2003, Chris Seaton &lt;<A HREF="mailto:chris@chrisseaton.com">chris@chrisseaton.com</A>&gt; wrote:
</I>&gt;<i> &gt; On Fri, 2003-10-31 at 01:29, Fergus Henderson wrote:
</I>&gt;<i> &gt; &gt; On 29-Oct-2003, Chris Seaton &lt;<A HREF="mailto:chris@chrisseaton.com">chris@chrisseaton.com</A>&gt; wrote:
</I>&gt;<i> &gt; &gt; &gt; How do I know what OS my program is running on at run time?
</I>&gt;<i> &gt; &gt;
</I>&gt;<i> &gt; &gt; Why do you care?
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; To select between GTK# and SWF.
</I>&gt;<i>
</I>&gt;<i> I can quite easily imagine systems on which both are supported.
</I>&gt;<i>
</I>&gt;<i> I would suggest something like this:
</I>&gt;<i>
</I>&gt;<i> bool prefer_gtk; // set by command-line option
</I>&gt;<i> // or environment variable
</I>&gt;<i>
</I>&gt;<i> if (prefer_gtk)
</I>&gt;<i> try {
</I>&gt;<i> code to use GTK#;
</I>&gt;<i> } catch (GTK# not availabe) {
</I>&gt;<i> code to use SWF;
</I>&gt;<i> }
</I>&gt;<i> } else {
</I>&gt;<i> try {
</I>&gt;<i> code to use SWF;
</I>&gt;<i> } catch (SWF not availabe) {
</I>&gt;<i> code to use GTK#;
</I>&gt;<i> }
</I>&gt;<i> }
</I>&gt;<i>
</I>&gt;<i> You can do this just for the first call, and save the results in a
</I>&gt;<i> variable which you then use to decide which GUI to use for later calls.
</I>&gt;<i>
</I>&gt;<i> It would be reasonable to use the OS setting to determine the default
</I>&gt;<i> value of prefer_gtk. But you should definitely try both, regardless of
</I>&gt;<i> which OS the platform claims to be.
</I>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="016667.html">[Mono-list] Determining the platform at compile and run time
</A></li>
<LI> Next message: <A HREF="016668.html">[Mono-list] Determining the platform at compile and run time
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16679">[ date ]</a>
<a href="thread.html#16679">[ thread ]</a>
<a href="subject.html#16679">[ subject ]</a>
<a href="author.html#16679">[ author ]</a>
</LI>
</UL>
</body></html>