[Mono-list] Determining the platform at compile and run time
A Rafael D Teixeira
rafaelteixeirabr@hotmail.com
Fri, 31 Oct 2003 05:23:13 -0200
>From: Fergus Henderson <fjh@cs.mu.OZ.AU>
>
>On 29-Oct-2003, Chris Seaton <chris@chrisseaton.com> wrote:
> > How do I know what OS my program is running on at run time?
>
>Why do you care?
>
>In general, it is a bad idea to test for particular operating systems.
In my case I needed to know which specific library to load and use. Because
the Windows version needed to PInvoke in the Win32 API (calling
FlushFileBuffers on an Stream handle), and the Mono one would have to make
an InternalCall (that would fsync the emulated Stream handle). Those things
were in a single piece of software before and would play havoc when
loaded/executed in the wrong CLI., what was always.
I used a modified PlugIn Pattern [Fowler - PoEAA], to make it transparent
for the Bamboo.Prevalence user, and without conditionally compiling two
different versions of the package.
I could use your try/catch solution, but I prefer to use "decisions
construed over known information" than "try/catch" for performance reasons.
Best regards,
Rafael Teixeira
Brazilian Polymath
Mono Hacker since 16 Jul 2001
MonoBrasil Founder
English Blog: http://monoblog.blogspot.com/
Brazilian Portuguese Blog: http://monoblog.weblogger.terra.com.br/
_________________________________________________________________
MSN Messenger: instale grátis e converse com seus amigos.
http://messenger.msn.com.br