fCraft.MonoCompat.MonoCompat C# (CSharp) Method

MonoCompat() static private method

static private MonoCompat ( ) : System
return System
        static MonoCompat()
        {
            Type monoRuntimeType = typeof( object ).Assembly.GetType( "Mono.Runtime" );

            if ( monoRuntimeType != null ) {
                IsMono = true;
                MethodInfo getDisplayNameMethod = monoRuntimeType.GetMethod( "GetDisplayName", MonoMethodFlags, null, Type.EmptyTypes, null );

                if ( getDisplayNameMethod != null ) {
                    MonoVersionString = ( string )getDisplayNameMethod.Invoke( null, null );

                    try {
                        Match versionMatch = VersionRegex.Match( MonoVersionString );
                        int major = Int32.Parse( versionMatch.Groups[1].Value );
                        int minor = Int32.Parse( versionMatch.Groups[2].Value );
                        int revision = Int32.Parse( versionMatch.Groups[3].Value );
                        MonoVersion = new Version( major, minor, revision );
                        IsSGenCapable = ( major == 2 && minor >= 8 );
                    } catch ( Exception ex ) {
                        throw new Exception( UnsupportedMessage, ex );
                    }

                    if ( MonoVersion.Major < 2 && MonoVersion.Major < 6 ) {
                        throw new Exception( UnsupportedMessage );
                    }
                } else {
                    throw new Exception( UnsupportedMessage );
                }
            }

            switch ( Environment.OSVersion.Platform ) {
                case PlatformID.MacOSX:
                case PlatformID.Unix:
                    IsMono = true;
                    IsWindows = false;
                    break;

                default:
                    IsWindows = true;
                    break;
            }

            IsCaseSensitive = !IsWindows;
        }