コード例 #1
0
 /// <summary>
 /// Clear the global context properties
 /// </summary>
 public void Clear()
 {
     lock (m_syncRoot)
     {
         m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
     }
 }
コード例 #2
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="propertiesDictionary">properties to copy</param>
 /// <remarks>
 /// <para>
 /// Initializes a new instance of the <see cref="T:log4net.Util.ReadOnlyPropertiesDictionary" /> class.
 /// </para>
 /// </remarks>
 public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary)
 {
     foreach (DictionaryEntry item in (IEnumerable)propertiesDictionary)
     {
         InnerHashtable.Add(item.Key, item.Value);
     }
 }
コード例 #3
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="propertiesDictionary">properties to copy</param>
 /// <remarks>
 /// <para>
 /// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class.
 /// </para>
 /// </remarks>
 public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary)
 {
     foreach (DictionaryEntry entry in propertiesDictionary)
     {
         InnerHashtable.Add(entry.Key, entry.Value);
     }
 }
コード例 #4
0
		/// <summary>
		/// Copy Constructor
		/// </summary>
		/// <param name="propertiesDictionary">properties to copy</param>
		/// <remarks>
		/// <para>
		/// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class.
		/// </para>
		/// </remarks>
		public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary)
		{
			foreach(DictionaryEntry entry in propertiesDictionary)
			{
				InnerHashtable.Add(entry.Key, entry.Value);
			}
		}
コード例 #5
0
 public PropertiesDictionary Flatten()
 {
     if (this.m_flattened == null)
     {
         this.m_flattened = new PropertiesDictionary();
         int count = this.m_nestedProperties.Count;
         while (--count >= 0)
         {
             ReadOnlyPropertiesDictionary dictionary = (ReadOnlyPropertiesDictionary)this.m_nestedProperties[count];
             IEnumerator enumerator = ((IEnumerable)dictionary).GetEnumerator();
             try
             {
                 while (enumerator.MoveNext())
                 {
                     DictionaryEntry current = (DictionaryEntry)enumerator.Current;
                     this.m_flattened[(string)current.Key] = current.Value;
                 }
             }
             finally
             {
                 IDisposable disposable = enumerator as IDisposable;
                 if (disposable != null)
                 {
                     disposable.Dispose();
                 }
             }
         }
     }
     return(this.m_flattened);
 }
コード例 #6
0
 public void Remove(string key)
 {
     lock (this.m_syncRoot)
     {
         if (this.m_readOnlyProperties.Contains(key))
         {
             PropertiesDictionary propertiesDictionary = new PropertiesDictionary(this.m_readOnlyProperties);
             propertiesDictionary.Remove(key);
             this.m_readOnlyProperties = new ReadOnlyPropertiesDictionary(propertiesDictionary);
         }
     }
 }
コード例 #7
0
        /// <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);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Gets or sets the value of a property
        /// </summary>
        /// <value>
        /// The value for the property with the specified key
        /// </value>
        /// <remarks>
        /// <para>
        /// Reading the value for a key is faster than setting the value.
        /// When the value is written a new read only copy of
        /// the properties is created.
        /// </para>
        /// </remarks>
        public override object this[string key]
        {
            get { return(m_readOnlyProperties[key]); }
            set
            {
                lock (m_syncRoot)
                {
                    var mutableProps = new PropertiesDictionary(m_readOnlyProperties);

                    mutableProps[key] = value;

                    m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Flatten this composite collection into a single properties dictionary
        /// </summary>
        /// <returns>the flattened dictionary</returns>
        /// <remarks>
        /// <para>
        /// Reduces the collection of ordered dictionaries to a single dictionary
        /// containing the resultant values for the keys.
        /// </para>
        /// </remarks>
        public PropertiesDictionary Flatten()
        {
            if (m_flattened == null)
            {
                m_flattened = new PropertiesDictionary();

                for (int i = m_nestedProperties.Count; --i >= 0;)
                {
                    ReadOnlyPropertiesDictionary cur = (ReadOnlyPropertiesDictionary)m_nestedProperties[i];

                    foreach (DictionaryEntry entry in cur)
                    {
                        m_flattened[(string)entry.Key] = entry.Value;
                    }
                }
            }
            return(m_flattened);
        }
コード例 #10
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);
     }
 }
コード例 #11
0
        public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary)
        {
            this.m_hashtable = new Hashtable();
            IEnumerator enumerator = ((IEnumerable)propertiesDictionary).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    DictionaryEntry current = (DictionaryEntry)enumerator.Current;
                    this.InnerHashtable.Add(current.Key, current.Value);
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }
コード例 #12
0
ファイル: CompositeProperties.cs プロジェクト: 89sos98/iveely
		/// <summary>
		/// Add a Properties Dictionary to this composite collection
		/// </summary>
		/// <param name="properties">the properties to add</param>
		/// <remarks>
		/// <para>
		/// Properties dictionaries added first take precedence over dictionaries added
		/// later.
		/// </para>
		/// </remarks>
		public void Add(ReadOnlyPropertiesDictionary properties)
		{
			m_flattened = null;
			m_nestedProperties.Add(properties);
		}
コード例 #13
0
 /// <summary>
 /// Add a Properties Dictionary to this composite collection
 /// </summary>
 /// <param name="properties">the properties to add</param>
 /// <remarks>
 /// <para>
 /// Properties dictionaries added first take precedence over dictionaries added
 /// later.
 /// </para>
 /// </remarks>
 public void Add(ReadOnlyPropertiesDictionary properties)
 {
     m_flattened = null;
     m_nestedProperties.Add(properties);
 }
コード例 #14
0
ファイル: PropertiesDictionary.cs プロジェクト: j2m2/CmisSync
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="propertiesDictionary">properties to copy</param>
		/// <remarks>
		/// <para>
		/// Initializes a new instance of the <see cref="PropertiesDictionary" /> class.
		/// </para>
		/// </remarks>
		public PropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary) : base(propertiesDictionary)
		{
		}
コード例 #15
0
        /// <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))
                {
                    var mutableProps = new PropertiesDictionary(m_readOnlyProperties);

                    mutableProps.Remove(key);

                    m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
                }
            }
        }
コード例 #16
0
 /// <summary>
 /// Clear the global context properties
 /// </summary>
 public void Clear()
 {
     lock (m_syncRoot)
     {
         m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
     }
 }
コード例 #17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="propertiesDictionary">properties to copy</param>
 /// <remarks>
 /// <para>
 /// Initializes a new instance of the <see cref="PropertiesDictionary" /> class.
 /// </para>
 /// </remarks>
 public PropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary) : base(propertiesDictionary)
 {
 }
コード例 #18
0
        /// <summary>
        /// Gets or sets the value of a property
        /// </summary>
        /// <value>
        /// The value for the property with the specified key
        /// </value>
        /// <remarks>
        /// <para>
        /// Reading the value for a key is faster than setting the value.
        /// When the value is written a new read only copy of 
        /// the properties is created.
        /// </para>
        /// </remarks>
        public override object this[string key]
        {
            get { return m_readOnlyProperties[key]; }
            set
            {
                lock (m_syncRoot)
                {
                    var mutableProps = new PropertiesDictionary(m_readOnlyProperties);

                    mutableProps[key] = value;

                    m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
                }
            }
        }