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); } } }
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(); }