Example #1
0
        public static String setProperty(String key, String value)
        {
            String oldValue = systemProperties.ContainsKey(key) ? getProperty(key) : null;

            systemProperties.Add(key, value);
            return(oldValue);
        }
Example #2
0
        public static util.Properties getProperties()
        {
            if (null == systemProperties)
            {
                // Collect the informations
                IDictionary          env  = Environment.GetEnvironmentVariables();
                java.util.Properties prop = new java.util.Properties(env);
                int    osMajor            = System.Environment.OSVersion.Version.Major;
                int    osMinior           = System.Environment.OSVersion.Version.Minor;
                int    osVersion          = osMajor * 10 + osMinior;
                String osName             = "Unknown";
                switch (System.Environment.OSVersion.Platform)
                {
                case PlatformID.WinCE:
                    osName = "Windows CE";
                    break;

                case PlatformID.Xbox:
                    osName = "XBox";
                    break;

                case PlatformID.Unix:
                    osName = "Unix";
                    break;

                case PlatformID.MacOSX:
                    osName = "MacOS";
                    break;

                case PlatformID.Win32S:
                    osName = "Windows 32";
                    break;

                case PlatformID.Win32Windows:
                    osName = "Windows ";
                    switch (osVersion)
                    {
                    case 40:
                        osName += "95";
                        break;

                    case 50:
                        osName += "98";
                        break;

                    case 130:
                        osName += "ME";
                        break;
                    }
                    break;

                case PlatformID.Win32NT:
                    osName = "Windows ";
                    switch (osVersion)
                    {
                    case 40:
                        osName += "NT 4.0";
                        break;

                    case 50:
                        osName += "2000";
                        break;

                    case 51:
                        osName += "XP";
                        break;

                    case 52:
                        osName += "Server 2003";
                        break;

                    case 60:
                        osName += "Vista";
                        break;

                    case 61:
                        osName += "7";
                        break;
                    }
                    break;
                }

                // store some Java system specific environment
                prop.Add("file.encoding", Encoding.Default.WebName);
                prop.Add("file.separator", "" + System.IO.Path.DirectorySeparatorChar);
                prop.Add("line.separator", System.Environment.NewLine);
                prop.Add("os.arch", System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"));
                prop.Add("os.name", osName);
                prop.Add("os.version", osMajor + "." + osMinior);
                prop.Add("path.separator", "" + System.IO.Path.PathSeparator);
                prop.Add("user.country", System.Globalization.CultureInfo.CurrentCulture.Name.Substring(3, 2));
                prop.Add("user.dir", System.Environment.CurrentDirectory);
                // Mono 2.6.4 BugFix:
                if (PlatformID.Unix == System.Environment.OSVersion.Platform)
                {
                    prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                }
                else
                { // UserProfile not exist in Mono 2.6.4
                    prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
                }
                prop.Add("user.language", System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
                prop.Add("user.name", System.Environment.UserName);
                prop.Add("user.timezone", null); // content???
                prop.Add("user.variant", null);  // content???
                // Java specific environment
                prop.Add("java.vendor", "Sebastian Ritter");
                prop.Add("java.version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                prop.Add("java.class.path", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                // Java net environment
                prop.Add("java.protocol.handler.pkgs", "biz.ritter.net.protocol|");
                // GUI specific environment
                prop.Add("awt.toolkit", "biz.ritter.awt.forms.FormsToolkit");
                // XML SAX/DOM/JAXP specific environment
                prop.Add("org.xml.sax.parser", null);                       // include the class for the default SAX Parser for example: org.apache.xerces.parsers.SaxParser
                prop.Add("javax.xml.parsers.SAXParserFactory", null);       // include the class for SAXParser for example: org.apache.xerces.jaxp.SAXParserFactoryImpl
                prop.Add("javax.xml.parsers.DocumentBuilderFactory", null); // include the class for DOMParser for example: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
                prop.Add("jaxp.debug", "false");                            // see f.e. javax.xml.parsers.FactoryFinder
                // Logging properties (see java.util.logging.LogManager)
                prop.Add("java.util.logging.config.class", null);
                prop.Add("java.util.logging.config.file", null);
                prop.Add("java.util.logging.manager", null);
                // IO properties
                prop.Add("java.io.tmpdir", System.IO.Path.GetTempPath());                 //using in logging FileHandler
                //Security properties - see java.security package
                prop.Add("java.security.properties", null);
                // Preferences properties
                prop.Add("java.util.prefs.PreferencesFactory", null);
                // JDBC properties
                prop.Add("jdbc.drivers", null);
                // Apache properties
                prop.Add("org.apache.xml.namespace.QName.useCompatibleSerialVersionUID", null);
                // ICU properties
                prop.Add("ICUDebug", null);
                // own important environment

                // Here it is...
                systemProperties = prop;
            }
            return(systemProperties);
        }
Example #3
0
        public static util.Properties getProperties()
        {
            if (null == systemProperties)
            {
                // Collect the informations
                IDictionary env = Environment.GetEnvironmentVariables();
                java.util.Properties prop = new java.util.Properties(env);
                int osMajor = System.Environment.OSVersion.Version.Major;
                int osMinior = System.Environment.OSVersion.Version.Minor;
                int osVersion = osMajor * 10 + osMinior;
                String osName = "Unknown";
                switch (System.Environment.OSVersion.Platform)
                {
                    case PlatformID.WinCE:
                        osName = "Windows CE";
                        break;
                    case PlatformID.Xbox :
                        osName = "XBox";
                        break;
                    case PlatformID.Unix:
                        osName = "Unix";
                        break;
                    case PlatformID.MacOSX:
                        osName = "MacOS";
                        break;
                    case PlatformID.Win32S:
                        osName = "Windows 32";
                        break;
                    case PlatformID.Win32Windows:
                        osName = "Windows ";
                        switch (osVersion)
                        {
                            case 40 :
                                osName += "95";
                                break;
                            case 50 :
                                osName += "98";
                                break;
                            case 130:
                                osName += "ME";
                                break;
                        }
                        break;
                    case PlatformID.Win32NT:
                        osName = "Windows ";
                        switch (osVersion)
                        {
                            case 40:
                                osName += "NT 4.0";
                                break;
                            case 50:
                                osName += "2000";
                                break;
                            case 51:
                                osName += "XP";
                                break;
                            case 52:
                                osName += "Server 2003";
                                break;
                            case 60:
                                osName += "Vista";
                                break;
                            case 61:
                                osName += "7";
                                break;
                        }
                        break;
                }

                // store some Java system specific environment
                prop.Add("file.encoding", Encoding.Default.WebName);
                prop.Add("file.separator", System.IO.Path.DirectorySeparatorChar);
                prop.Add("line.separator", System.Environment.NewLine);
                prop.Add("os.arch", System.Environment.GetEnvironmentVariable ("PROCESSOR_ARCHITEW6432"));
                prop.Add("os.name", osName);
                prop.Add("os.version", osMajor+"."+osMinior);
                prop.Add("path.separator", System.IO.Path.PathSeparator);
                prop.Add("user.country", System.Globalization.CultureInfo.CurrentCulture.Name.Substring(3, 2));
                prop.Add("user.dir", System.Environment.CurrentDirectory);
                // Mono 2.6.4 BugFix:
                if (PlatformID.Unix == System.Environment.OSVersion.Platform)
                {
                    prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                }
                else
                { // UserProfile not exist in Mono 2.6.4
                    //prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
                    //.net frame 3.4 has not Environment.SpecialFolder.UserProfile

                    prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.Personal));

                    //need 4.0 support
                    //prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
                }
                prop.Add("user.language", System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
                prop.Add("user.name", System.Environment.UserName);
                prop.Add("user.timezone", null); // content???
                prop.Add("user.variant", null); // content???
                // Java specific environment
                prop.Add("java.vendor","Sebastian Ritter");
                prop.Add("java.version",System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                prop.Add("java.class.path", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                // own important environment

                // Here it is...
                systemProperties = prop;
            }
            return systemProperties;
        }
Example #4
0
        public static util.Properties getProperties()
        {
            if (null == systemProperties)
            {
                // Collect the informations
                IDictionary env = Environment.GetEnvironmentVariables();
                java.util.Properties prop = new java.util.Properties(env);
                int osMajor = System.Environment.OSVersion.Version.Major;
                int osMinior = System.Environment.OSVersion.Version.Minor;
                int osVersion = osMajor * 10 + osMinior;
                String osName = "Unknown";
                switch (System.Environment.OSVersion.Platform)
                {
                    case PlatformID.WinCE:
                        osName = "Windows CE";
                        break;
                    case PlatformID.Xbox :
                        osName = "XBox";
                        break;
                    case PlatformID.Unix:
                        osName = "Unix";
                        break;
                    case PlatformID.MacOSX:
                        osName = "MacOS";
                        break;
                    case PlatformID.Win32S:
                        osName = "Windows 32";
                        break;
                    case PlatformID.Win32Windows:
                        osName = "Windows ";
                        switch (osVersion)
                        {
                            case 40 :
                                osName += "95";
                                break;
                            case 50 :
                                osName += "98";
                                break;
                            case 130:
                                osName += "ME";
                                break;
                        }
                        break;
                    case PlatformID.Win32NT:
                        osName = "Windows ";
                        switch (osVersion)
                        {
                            case 40:
                                osName += "NT 4.0";
                                break;
                            case 50:
                                osName += "2000";
                                break;
                            case 51:
                                osName += "XP";
                                break;
                            case 52:
                                osName += "Server 2003";
                                break;
                            case 60:
                                osName += "Vista";
                                break;
                            case 61:
                                osName += "7";
                                break;
                        }
                        break;
                }

                // store some Java system specific environment
                prop.Add("file.encoding", Encoding.Default.WebName);
                prop.Add("file.separator", ""+System.IO.Path.DirectorySeparatorChar);
                prop.Add("line.separator", System.Environment.NewLine);
                prop.Add("os.arch", System.Environment.GetEnvironmentVariable ("PROCESSOR_ARCHITEW6432"));
                prop.Add("os.name", osName);
                prop.Add("os.version", osMajor+"."+osMinior);
                prop.Add("path.separator", ""+System.IO.Path.PathSeparator);
                prop.Add("user.country", System.Globalization.CultureInfo.CurrentCulture.Name.Substring(3, 2));
                prop.Add("user.dir", System.Environment.CurrentDirectory);
                // Mono 2.6.4 BugFix:
                if (PlatformID.Unix == System.Environment.OSVersion.Platform)
                {
                    prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                }
                else
                { // UserProfile not exist in Mono 2.6.4
                    prop.Add("user.home", Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
                }
                prop.Add("user.language", System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
                prop.Add("user.name", System.Environment.UserName);
                prop.Add("user.timezone", null); // content???
                prop.Add("user.variant", null); // content???
                // Java specific environment
                prop.Add("java.vendor","Sebastian Ritter");
                prop.Add("java.version",System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                prop.Add("java.class.path", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
                // Java net environment
                prop.Add("java.protocol.handler.pkgs", "biz.ritter.net.protocol|");
                // GUI specific environment
                prop.Add("awt.toolkit", "biz.ritter.awt.forms.FormsToolkit");
                // XML SAX/DOM/JAXP specific environment
                prop.Add("org.xml.sax.parser", null);// include the class for the default SAX Parser for example: org.apache.xerces.parsers.SaxParser
                prop.Add("javax.xml.parsers.SAXParserFactory", null); // include the class for SAXParser for example: org.apache.xerces.jaxp.SAXParserFactoryImpl
                prop.Add("javax.xml.parsers.DocumentBuilderFactory", null); // include the class for DOMParser for example: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
                prop.Add ("jaxp.debug", "false"); // see f.e. javax.xml.parsers.FactoryFinder
                // Logging properties (see java.util.logging.LogManager)
                prop.Add("java.util.logging.config.class", null);
                prop.Add("java.util.logging.config.file", null);
                prop.Add("java.util.logging.manager", null);
                // IO properties
                prop.Add("java.io.tmpdir", System.IO.Path.GetTempPath()); //using in logging FileHandler
                //Security properties - see java.security package
                prop.Add("java.security.properties", null);
                // Preferences properties
                prop.Add("java.util.prefs.PreferencesFactory", null);
                // JDBC properties
                prop.Add("jdbc.drivers", null);
                // Apache properties
                prop.Add("org.apache.xml.namespace.QName.useCompatibleSerialVersionUID", null);
                // ICU properties
                prop.Add("ICUDebug", null);
                // own important environment

                // Here it is...
                systemProperties = prop;
            }
            return systemProperties;
        }