Exemple #1
0
        /// <summary>
        /// Returns a new settings object with the settings specified in the file as key value pair. Settings not beeing specified in this file will have the default value.
        /// </summary>
        /// <param name="settingLocation">Full qualified name of the settings file.</param>
        /// <returns>A settings object with the values specified in the file.</returns>
        public static ML_Settings readSettingsFromFile(string settingLocation)
        {
            ML_Settings mls = new ML_Settings();

            if (System.IO.File.Exists(settingLocation) == false)
            {
                GlobalState.logError.logLine("Could not load ML settings file! File (" + settingLocation + ") does not exit.");
                return(mls);
            }
            System.IO.StreamReader file = new System.IO.StreamReader(settingLocation);
            string line;

            while ((line = file.ReadLine()) != null)
            {
                string[] nameAndValue = line.Split(new char[] { ' ' }, 2);
                if (!mls.setSetting(nameAndValue[0], nameAndValue[1]))
                {
                    GlobalState.logError.logLine("MlSetting " + nameAndValue[0] + " not found!");
                }
            }
            file.Close();

            if (GlobalState.varModel != null && mls.blacklisted.Count > 0)
            {
                mls.checkAndCleanBlacklisted();
            }

            return(mls);
        }
Exemple #2
0
        /// <summary>
        /// Returns a new settings object with the settings specified in the file as key value pair. Settings not beeing specified in this file will have the default value.
        /// </summary>
        /// <param name="settings">All settings to be changed in a string with whitespaces as separator .</param>
        /// <returns>A settings object with the values specified in the file.</returns>
        public static ML_Settings readSettings(string settings)
        {
            settings = settings.Trim();
            settings = settings.Replace(System.Environment.NewLine, "");
            ML_Settings mls = new ML_Settings();

            String[] settingArray = settings.Split(' ');

            for (int i = 0; i < settingArray.Length; i++)
            {
                string[] nameAndValue = settingArray[i].Split(new char[] { ':' }, 2);
                if (!mls.setSetting(nameAndValue[0], nameAndValue[1]))
                {
                    GlobalState.logError.logLine("MlSetting " + nameAndValue[0] + " not found!");
                }
            }

            if (GlobalState.varModel != null && mls.blacklisted.Count > 0)
            {
                mls.checkAndCleanBlacklisted();
            }

            return(mls);
        }