/// <summary>
        /// Remove a property from the global context
        /// </summary>
        /// <param name="key">the key for the entry to remove</param>
        /// <remarks>
        /// <para>
        /// Removing an entry from the global context properties is relatively expensive compared
        /// with reading a value.
        /// </para>
        /// </remarks>
        public void Remove(string key)
        {
            lock (m_syncRoot)
            {
                if (m_readOnlyProperties.Contains(key))
                {
                    PropertiesDictionary mutableProps = new PropertiesDictionary(m_readOnlyProperties);

                    mutableProps.Remove(key);

                    m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
                }
            }
        }
Example #2
0
 public object this[string key]
 {
     get
     {
         object obj2;
         if (this.m_flattened != null)
         {
             return(this.m_flattened[key]);
         }
         IEnumerator enumerator = this.m_nestedProperties.GetEnumerator();
         try
         {
             while (true)
             {
                 if (enumerator.MoveNext())
                 {
                     ReadOnlyPropertiesDictionary current = (ReadOnlyPropertiesDictionary)enumerator.Current;
                     if (!current.Contains(key))
                     {
                         continue;
                     }
                     obj2 = current[key];
                 }
                 else
                 {
                     return(null);
                 }
                 break;
             }
         }
         finally
         {
             IDisposable disposable = enumerator as IDisposable;
             if (disposable != null)
             {
                 disposable.Dispose();
             }
         }
         return(obj2);
     }
 }