#region Apache License // // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to you under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #endregion using System; using System.Collections; #if !NETCF using System.Runtime.Serialization; using System.Xml; #endif namespace log4net.Util { /// /// String keyed object map. /// /// /// /// While this collection is serializable only member /// objects that are serializable will /// be serialized along with this collection. /// /// /// Nicko Cadell /// Gert Driesen #if NETCF public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, IDictionary #else [Serializable] public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ISerializable, IDictionary #endif { #region Public Instance Constructors /// /// Constructor /// /// /// /// Initializes a new instance of the class. /// /// public PropertiesDictionary() { } /// /// Constructor /// /// properties to copy /// /// /// Initializes a new instance of the class. /// /// public PropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary) : base(propertiesDictionary) { } #endregion Public Instance Constructors #region Private Instance Constructors #if !NETCF /// /// Initializes a new instance of the class /// with serialized data. /// /// The that holds the serialized object data. /// The that contains contextual information about the source or destination. /// /// /// Because this class is sealed the serialization constructor is private. /// /// private PropertiesDictionary(SerializationInfo info, StreamingContext context) : base(info, context) { } #endif #endregion Protected Instance Constructors #region Public Instance Properties /// /// Gets or sets the value of the property with the specified key. /// /// /// The value of the property with the specified key. /// /// The key of the property to get or set. /// /// /// The property value will only be serialized if it is serializable. /// If it cannot be serialized it will be silently ignored if /// a serialization operation is performed. /// /// override public object this[string key] { get { return InnerHashtable[key]; } set { InnerHashtable[key] = value; } } #endregion Public Instance Properties #region Public Instance Methods /// /// Remove the entry with the specified key from this dictionary /// /// the key for the entry to remove /// /// /// Remove the entry with the specified key from this dictionary /// /// public void Remove(string key) { InnerHashtable.Remove(key); } #endregion Public Instance Methods #region Implementation of IDictionary /// /// See /// /// an enumerator /// /// /// Returns a over the contest of this collection. /// /// IDictionaryEnumerator IDictionary.GetEnumerator() { return InnerHashtable.GetEnumerator(); } /// /// See /// /// the key to remove /// /// /// Remove the entry with the specified key from this dictionary /// /// void IDictionary.Remove(object key) { InnerHashtable.Remove(key); } /// /// See /// /// the key to lookup in the collection /// true if the collection contains the specified key /// /// /// Test if this collection contains a specified key. /// /// bool IDictionary.Contains(object key) { return InnerHashtable.Contains(key); } /// /// Remove all properties from the properties collection /// /// /// /// Remove all properties from the properties collection /// /// public override void Clear() { InnerHashtable.Clear(); } /// /// See /// /// the key /// the value to store for the key /// /// /// Store a value for the specified . /// /// /// Thrown if the is not a string void IDictionary.Add(object key, object value) { if (!(key is string)) { throw new ArgumentException("key must be a string", "key"); } InnerHashtable.Add(key, value); } /// /// See /// /// /// false /// /// /// /// This collection is modifiable. This property always /// returns false. /// /// bool IDictionary.IsReadOnly { get { return false; } } /// /// See /// /// /// The value for the key specified. /// /// /// /// Get or set a value for the specified . /// /// /// Thrown if the is not a string object IDictionary.this[object key] { get { if (!(key is string)) { throw new ArgumentException("key must be a string", "key"); } return InnerHashtable[key]; } set { if (!(key is string)) { throw new ArgumentException("key must be a string", "key"); } InnerHashtable[key] = value; } } /// /// See /// ICollection IDictionary.Values { get { return InnerHashtable.Values; } } /// /// See /// ICollection IDictionary.Keys { get { return InnerHashtable.Keys; } } /// /// See /// bool IDictionary.IsFixedSize { get { return false; } } #endregion #region Implementation of ICollection /// /// See /// /// /// void ICollection.CopyTo(Array array, int index) { InnerHashtable.CopyTo(array, index); } /// /// See /// bool ICollection.IsSynchronized { get { return InnerHashtable.IsSynchronized; } } /// /// See /// object ICollection.SyncRoot { get { return InnerHashtable.SyncRoot; } } #endregion #region Implementation of IEnumerable /// /// See /// IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)InnerHashtable).GetEnumerator(); } #endregion } }