Ejemplo n.º 1
0
 public void setConfigValue(CONFIGKEY KeySet, object ValueSet)
 {
     if (ValueSet != null && ValueSet.GetType() == typeof(string))
     {
         if (lstConfig.ContainsKey(KeySet))
         {
             lstConfig[KeySet] = SecuritiesLib.EncryptString((string)ValueSet, PASS_ENCRYPT);
         }
         else
         {
             lstConfig.Add(KeySet, SecuritiesLib.EncryptString((string)ValueSet, PASS_ENCRYPT));
         }
     }
     else
     {
         if (lstConfig.ContainsKey(KeySet))
         {
             lstConfig[KeySet] = ValueSet;
         }
         else
         {
             lstConfig.Add(KeySet, ValueSet);
         }
     }
 }
Ejemplo n.º 2
0
 public object getConfigValue(CONFIGKEY KeyGet)
 {
     if (lstConfig.Contains(KeyGet))
     {
         object val = lstConfig[KeyGet];
         if (val == null)
         {
             return(null);
         }
         if (val.GetType() == typeof(string))
         {
             return(SecuritiesLib.DecryptString((string)val, PASS_ENCRYPT));
         }
         else
         {
             return(lstConfig[KeyGet]);
         }
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        public void LoadConfig()
        {
            if (!File.Exists(Environment.CurrentDirectory + CONFIG_FILENAME))
            {
                lstConfig[CONFIGKEY.DB_CONNECTION_STRING] = SecuritiesLib.EncryptString(DefaultConnectionString(), PASS_ENCRYPT);
                foreach (CONFIGKEY val in Enum.GetValues(typeof(CONFIGKEY)))
                {
                    if (val != CONFIGKEY.DB_CONNECTION_STRING)
                    {
                        lstConfig[val] = null;
                    }
                }

                SaveConfig();
                return;
            }

            Stream          s      = File.Open(Environment.CurrentDirectory + CONFIG_FILENAME, FileMode.Open, FileAccess.Read);
            BinaryFormatter binary = new BinaryFormatter();

            s.Position = 0;
            lstConfig  = (Hashtable)binary.Deserialize(s);
            s.Close();
        }