예제 #1
0
 public void Remove(EnvKey key)
 {
     if (this.values == null)
     {
         return;
     }
     this.values.Remove(key);
     if (this.values.Count == 0)
     {
         this.values = null;
     }
 }
예제 #2
0
 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;
     }
 }
예제 #3
0
        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);
            }
        }