I came up with a temporary solution for now similar to what the site
descibes:
public class OSDetection
    {
        static public bool IsWindows
        {
            get
            {
                return Environment.OSVersion.Platform != PlatformID.Unix;
            }
        }

        static public bool IsOSX
        {
            get
            {
                bool retVal = false;
                if (!IsWindows)
                {
                    ProcessStartInfo si = new ProcessStartInfo("uname",
"-s");
                    si.RedirectStandardOutput = true;
                    si.UseShellExecute = false;

                    string outputString = string.Empty;
                    using (Process p = Process.Start(si))
                    {
                        p.Start();
                        outputString = p.StandardOutput.ReadLine();
                        p.WaitForExit();
                    }

                    retVal = string.Compare(outputString, "darwin", true) ==
0;
                }

                return retVal;
            }
        }

        static public bool IsLinux
        {
            get
            {
                bool retVal = false;
                if (!IsWindows)
                {
                    ProcessStartInfo si = new ProcessStartInfo("uname",
"-s");
                    si.RedirectStandardOutput = true;
                    si.UseShellExecute = false;

                    string outputString = string.Empty;
                    using (Process p = Process.Start(si))
                    {
                        p.Start();
                        outputString = p.StandardOutput.ReadLine();
                        p.WaitForExit();
                    }

                    retVal = string.Compare(outputString, "linux", true) ==
0;
                }

                return retVal;
            }
        }
    }

On Wed, Mar 26, 2008 at 11:06 PM, Oleg Deribas <
[EMAIL PROTECTED]> wrote:

> Hi,
>
> Scott Graves wrote:
>
> > I now have a requirement to execute a method based on the targeted OS.
> > As of today, the code is 100% portable across OS X, Linux, and Wn32.
> > Using the mono framework, is there a way to determine this by using a
> > Conditional attribute or any other means?
>
> Partially it is described here:
>
> http://mono-project.com/FAQ:_Technical#How_to_detect_the_execution_platform_.3F
>
> --
> Oleg
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
_______________________________________________
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to