logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject cvs commit: logging-log4net/src/Plugin PluginCollection.cs
Date Sun, 19 Dec 2004 19:23:54 GMT
nicko       2004/12/19 11:23:54

  Modified:    src/Plugin PluginCollection.cs
  Log:
  Updates suggested by FxCop.
  Minor naming changes to internal types.
  Perf improvements to type check + type cast code.
  
  Revision  Changes    Path
  1.9       +17 -230   logging-log4net/src/Plugin/PluginCollection.cs
  
  Index: PluginCollection.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/Plugin/PluginCollection.cs,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PluginCollection.cs	13 Dec 2004 01:42:51 -0000	1.8
  +++ PluginCollection.cs	19 Dec 2004 19:23:54 -0000	1.9
  @@ -25,9 +25,6 @@
   	///	A strongly-typed collection of <see cref="IPlugin"/> objects.
   	/// </summary>
   	/// <author>Nicko Cadell</author>
  -#if !NETCF
  -	[Serializable]
  -#endif
   	public class PluginCollection : ICollection, IList, IEnumerable, ICloneable
   	{
   		#region Interfaces
  @@ -68,12 +65,7 @@
   		#region Implementation (data)
   
   		private IPlugin[] m_array;
  -
   		private int m_count = 0;
  -
  -#if !NETCF
  -		[NonSerialized]
  -#endif
   		private int m_version = 0;
   
   		#endregion Implementation (data)
  @@ -81,20 +73,6 @@
   		#region Static Wrappers
   
   		/// <summary>
  -		///	Creates a synchronized (thread-safe) wrapper for a <c>PluginCollection</c>
instance.
  -		/// </summary>
  -		/// <param name="list">list to create a synchronized wrapper arround</param>
  -		/// <returns>
  -		/// A <c>PluginCollection</c> wrapper that is synchronized (thread-safe).
  -		/// </returns>
  -		public static PluginCollection Synchronized(PluginCollection list)
  -		{
  -			if(list == null) throw new ArgumentNullException("list");
  -
  -			return new SyncPluginCollection(list);
  -		}
  -        
  -		/// <summary>
   		///	Creates a read-only wrapper for a <c>PluginCollection</c> instance.
   		/// </summary>
   		/// <param name="list">list to create a readonly wrapper arround</param>
  @@ -107,9 +85,11 @@
   
   			return new ReadOnlyPluginCollection(list);
   		}
  +
   		#endregion
   
  -		#region Construction
  +		#region Constructors
  +
   		/// <summary>
   		///	Initializes a new instance of the <c>PluginCollection</c> class
   		///	that is empty and has the default initial capacity.
  @@ -169,7 +149,7 @@
   		/// Used to access protected constructor
   		/// </summary>
   		/// <exclude/>
  -		protected enum Tag 
  +		protected internal enum Tag 
   		{
   			/// <summary>
   			/// A value
  @@ -182,10 +162,11 @@
   		/// </summary>
   		/// <param name="tag"></param>
   		/// <exclude/>
  -		protected PluginCollection(Tag tag)
  +		protected internal PluginCollection(Tag tag)
   		{
   			m_array = null;
   		}
  +
   		#endregion
   		
   		#region Operations (type-safe ICollection)
  @@ -247,6 +228,7 @@
   		#endregion
   		
   		#region Operations (type-safe IList)
  +
   		/// <summary>
   		/// Gets or sets the <see cref="IPlugin"/> at the specified index.
   		/// </summary>
  @@ -446,6 +428,7 @@
   		{
   			get { return false; }
   		}
  +
   		#endregion
   
   		#region Operations (type-safe IEnumerable)
  @@ -458,6 +441,7 @@
   		{
   			return new Enumerator(this);
   		}
  +
   		#endregion
   
   		#region Public helpers (just to mimic some nice features of ArrayList)
  @@ -672,7 +656,7 @@
   		{
   			#region Implementation (data)
   			
  -			private PluginCollection m_collection;
  +			private readonly PluginCollection m_collection;
   			private int m_index;
   			private int m_version;
   			
  @@ -724,7 +708,7 @@
   				}
   
   				++m_index;
  -				return (m_index < m_collection.Count) ? true : false;
  +				return (m_index < m_collection.Count);
   			}
   
   			/// <summary>
  @@ -734,13 +718,14 @@
   			{
   				m_index = -1;
   			}
  +
   			#endregion
   	
   			#region Implementation (IEnumerator)
   			
   			object IEnumerator.Current
   			{
  -				get { return (object)(this.Current); }
  +				get { return this.Current; }
   			}
   			
   			#endregion
  @@ -748,207 +733,6 @@
   
   		#endregion
   
  -		#region Nested Synchronized Wrapper class
  -
  -		/// <exclude/>
  -		private sealed class SyncPluginCollection : PluginCollection
  -		{
  -			#region Implementation (data)
  -			private PluginCollection m_collection;
  -			private object m_root;
  -			#endregion
  -
  -			#region Construction
  -
  -			internal SyncPluginCollection(PluginCollection list) : base(Tag.Default)
  -			{
  -				m_root = list.SyncRoot;
  -				m_collection = list;
  -			}
  -
  -			#endregion
  -
  -			#region Type-safe ICollection
  -
  -			public override void CopyTo(IPlugin[] array)
  -			{
  -				lock(this.m_root)
  -				{
  -					m_collection.CopyTo(array);
  -				}
  -			}
  -
  -			public override void CopyTo(IPlugin[] array, int start)
  -			{
  -				lock(this.m_root)
  -				{
  -					m_collection.CopyTo(array,start);
  -				}
  -			}
  -			public override int Count
  -			{
  -				get
  -				{ 
  -					lock(this.m_root)
  -					{
  -						return m_collection.Count;
  -					}
  -				}
  -			}
  -
  -			public override bool IsSynchronized
  -			{
  -				get { return true; }
  -			}
  -
  -			public override object SyncRoot
  -			{
  -				get { return this.m_root; }
  -			}
  -
  -			#endregion
  -
  -			#region Type-safe IList
  -
  -			public override IPlugin this[int i]
  -			{
  -				get
  -				{
  -					lock(this.m_root)
  -					{
  -						return m_collection[i];
  -					}
  -				}
  -				set
  -				{
  -					lock(this.m_root)
  -					{
  -						m_collection[i] = value; 
  -					}
  -				}
  -			}
  -
  -			public override int Add(IPlugin x)
  -			{
  -				lock(this.m_root)
  -				{
  -					return m_collection.Add(x);
  -				}
  -			}
  -            
  -			public override void Clear()
  -			{
  -				lock(this.m_root)
  -				{
  -					m_collection.Clear();
  -				}
  -			}
  -
  -			public override bool Contains(IPlugin x)
  -			{
  -				lock(this.m_root)
  -				{
  -					return m_collection.Contains(x);
  -				}
  -			}
  -
  -			public override int IndexOf(IPlugin x)
  -			{
  -				lock(this.m_root)
  -				{
  -					return m_collection.IndexOf(x);
  -				}
  -			}
  -
  -			public override void Insert(int pos, IPlugin x)
  -			{
  -				lock(this.m_root)
  -				{
  -					m_collection.Insert(pos,x);
  -				}
  -			}
  -
  -			public override void Remove(IPlugin x)
  -			{           
  -				lock(this.m_root)
  -				{
  -					m_collection.Remove(x);
  -				}
  -			}
  -
  -			public override void RemoveAt(int pos)
  -			{
  -				lock(this.m_root)
  -				{
  -					m_collection.RemoveAt(pos);
  -				}
  -			}
  -            
  -			public override bool IsFixedSize
  -			{
  -				get { return m_collection.IsFixedSize; }
  -			}
  -
  -			public override bool IsReadOnly
  -			{
  -				get { return m_collection.IsReadOnly; }
  -			}
  -			#endregion
  -
  -			#region Type-safe IEnumerable
  -
  -			public override IPluginCollectionEnumerator GetEnumerator()
  -			{
  -				lock(m_root)
  -				{
  -					return m_collection.GetEnumerator();
  -				}
  -			}
  -
  -			#endregion
  -
  -			#region Public Helpers
  -
  -			// (just to mimic some nice features of ArrayList)
  -			public override int Capacity
  -			{
  -				get
  -				{
  -					lock(this.m_root)
  -					{
  -						return m_collection.Capacity;
  -					}
  -				}
  -				set
  -				{
  -					lock(this.m_root)
  -					{
  -						m_collection.Capacity = value;
  -					}
  -				}
  -			}
  -
  -			public override int AddRange(PluginCollection x)
  -			{
  -				lock(this.m_root)
  -				{
  -					return m_collection.AddRange(x);
  -				}
  -			}
  -
  -			public override int AddRange(IPlugin[] x)
  -			{
  -				lock(this.m_root)
  -				{
  -					return m_collection.AddRange(x);
  -				}
  -			}
  -
  -			#endregion
  -		}
  -
  -		#endregion
  -
   		#region Nested Read Only Wrapper class
   
   		/// <exclude/>
  @@ -956,7 +740,7 @@
   		{
   			#region Implementation (data)
   
  -			private PluginCollection m_collection;
  +			private readonly PluginCollection m_collection;
   
   			#endregion
   
  @@ -970,6 +754,7 @@
   			#endregion
   
   			#region Type-safe ICollection
  +
   			public override void CopyTo(IPlugin[] array)
   			{
   				m_collection.CopyTo(array);
  @@ -997,6 +782,7 @@
   			#endregion
   
   			#region Type-safe IList
  +
   			public override IPlugin this[int i]
   			{
   				get { return m_collection[i]; }
  @@ -1047,6 +833,7 @@
   			{
   				get { return true; }
   			}
  +
   			#endregion
   
   			#region Type-safe IEnumerable
  
  
  

Mime
View raw message