public void Remove(EnvKey key) { if (this.values == null) { return; } this.values.Remove(key); if (this.values.Count == 0) { this.values = null; } }
public object this[EnvKey key] { get { return(this.values[key]); } set { if (this.values == null) { this.values = new Dictionary <EnvKey, object>(); } this.values[key] = value; } }
public T Get <T>(EnvKey key) { if (this.values == null || !this.values.ContainsKey(key)) { return(default(T)); } object value = values[key]; try { return((T)value); } catch (InvalidCastException e) { throw new Exception($"不能把{value.GetType()}转换为{typeof(T)}", e); } }