Esempio n. 1
0
 public void Set(ConfigObject obj, bool overWrite = false)
 {
     //Store the object in list. If it already exists, throw error if overWrite is false.
     if (Contains(obj.Key) && overWrite == false)
     {
         throw new Exception("An object with same key already exists. ");
     }
     if (Contains(obj.Key) && overWrite)
     {
         Remove(obj.Key);
     }
     Objects.Add(obj);
 }
Esempio n. 2
0
        /// <summary>
        /// Sets or adds a an object in the database with specified key and value.
        /// </summary>
        /// <typeparam name="T">The type of the object. </typeparam>
        /// <param name="key">THe key for the object. Must be unique.</param>
        /// <param name="value">Value</param>
        public void Set <T>(string key, T value)
        {
            ConfigObject co = new ConfigObject()
            {
                Key = key, Object = value, Type = typeof(T)
            };

            this.Database.Set(co, true);
            if (AutoSave)
            {
                Save();
            }
        }