public void RemoveSetting(MetaConfiguration config, int index) { object key = new MetaProp { Config = config, UserIndex = index }; _dict.Remove(key); }
/// <summary> /// Whether the key is currently used to store a User Setting. /// </summary> /// <param name="key">The key to check</param> /// <returns>Whether the key is currenty used</returns> public bool HasKey(MetaConfiguration config, int index) { var key = new MetaProp { Config = config, UserIndex = index }; return(_dict.ContainsKey(key)); }
/// <summary> /// Sets the relationship between the key (composited from the /// meta-configuration and the index) and the setting /// (encapsulated in the object 'value'). /// </summary> /// <param name="config">the meta configuration value</param> /// <param name="index">the index</param> /// <param name="value">the setting value</param> /// <returns></returns> public bool SetSetting(MetaConfiguration config, int index, object value) { object key = new MetaProp { Config = config, UserIndex = index }; bool bAlreadyContains = _dict.ContainsKey(key); _dict[key] = value; return(bAlreadyContains); }
public T RemoveSetting <T>(MetaConfiguration config, int index) { var key = new MetaProp { Config = config, UserIndex = index }; object value; if (_dict.TryGetValue(key, out value)) { _dict.Remove(key); return((T)value); } return(default(T)); }
public T GetSetting <T>(MetaConfiguration config, int index) { var key = new MetaProp { Config = config, UserIndex = index }; if (_dict.ContainsKey(key) && _dict[key].GetType() == typeof(T)) { return((T)_dict[key]); } #if UNITY_EDITOR UnityEngine.Debug.LogWarning(string.Format("Could not find key: ({0}, {1})", config, index)); #endif return(default(T)); }
/// <summary> /// Protected method to actually add any <see cref="MetaConfiguration"/> object. /// </summary> /// <param name="m">A meta configuration to add.</param> protected void AddMeta(MetaConfiguration m) { _configurations.Add(m); }