Exemplo n.º 1
0
        public static bool SetValue(String strName, object objValue)
        {
            try
            {
                for (int i = 0; i < m_lstSettings.Count; i++)
                {
                    SSettings Settings = m_lstSettings[i];
                    if (Settings.strName == strName)
                    {
                        Settings.objValue = objValue;
                        m_lstSettings[i]  = Settings;
                        return(true);
                    }
                }

                SSettings New_Settings = new SSettings();
                New_Settings.strName  = strName;
                New_Settings.objValue = objValue;
                m_lstSettings.Add(New_Settings);
                return(true);
            }
            catch
            {
            }
            return(false);
        }
Exemplo n.º 2
0
        public static bool LoadSettings()
        {
            try
            {
                if (m_lstSettings == null)
                {
                    m_lstSettings = new List <SSettings>();
                }

                m_lstSettings.Clear();

                if (!File.Exists(Settings_File))
                {
                    return(false);
                }

                String[] arr_strSettings = File.ReadAllLines(Settings_File);

                if (arr_strSettings.Length == 0)
                {
                    return(false);
                }

                foreach (String strSettings in arr_strSettings)
                {
                    String[] arr_strData = strSettings.Split('=');

                    if (arr_strData.Length != 2)
                    {
                        continue;
                    }

                    SSettings Settings = new SSettings();
                    Settings.strName  = arr_strData[0];
                    Settings.objValue = (object)arr_strData[1];

                    m_lstSettings.Add(Settings);
                }
                return(true);
            }
            catch
            {
            }
            return(false);
        }