コード例 #1
0
ファイル: AppenderCollection.cs プロジェクト: Vizzini/netgore
        /// <summary>
        /// Creates a read-only wrapper for a <c>AppenderCollection</c> instance.
        /// </summary>
        /// <param name="list">list to create a readonly wrapper arround</param>
        /// <returns>
        /// An <c>AppenderCollection</c> wrapper that is read-only.
        /// </returns>
        public static AppenderCollection ReadOnly(AppenderCollection list)
        {
            if (list == null)
                throw new ArgumentNullException("list");

            return new ReadOnlyAppenderCollection(list);
        }
コード例 #2
0
 /// <summary>
 /// Creates a synchronized (thread-safe) wrapper for a
 /// <c>AppenderCollection</c> instance.
 /// </summary>
 /// <returns>
 /// An <c>AppenderCollection</c> wrapper that is synchronized (thread-safe).
 /// </returns>
 public static AppenderCollection Synchronized(AppenderCollection list)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     return(new SyncAppenderCollection(list));
 }
コード例 #3
0
 /// <summary>
 /// Creates a read-only wrapper for a <c>AppenderCollection</c> instance.
 /// </summary>
 /// <param name="list">list to create a readonly wrapper arround</param>
 /// <returns>
 /// An <c>AppenderCollection</c> wrapper that is read-only.
 /// </returns>
 public static AppenderCollection ReadOnly(AppenderCollection list)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     return(new ReadOnlyAppenderCollection(list));
 }
コード例 #4
0
        public virtual object Clone()
        {
            AppenderCollection appenders = new AppenderCollection(this.m_count);

            Array.Copy(this.m_array, 0, appenders.m_array, 0, this.m_count);
            appenders.m_count   = this.m_count;
            appenders.m_version = this.m_version;
            return(appenders);
        }
コード例 #5
0
        /// <summary>
        /// Creates a shallow copy of the <see cref="T:log4net.Appender.AppenderCollection" />.
        /// </summary>
        /// <returns>A new <see cref="T:log4net.Appender.AppenderCollection" /> with a shallow copy of the collection data.</returns>
        public virtual object Clone()
        {
            AppenderCollection appenderCollection = new AppenderCollection(m_count);

            Array.Copy(m_array, 0, appenderCollection.m_array, 0, m_count);
            appenderCollection.m_count   = m_count;
            appenderCollection.m_version = m_version;
            return(appenderCollection);
        }
コード例 #6
0
        /// <summary>
        /// Creates a shallow copy of the <see cref="AppenderCollection"/>.
        /// </summary>
        /// <returns>A new <see cref="AppenderCollection"/> with a shallow copy of the collection data.</returns>
        public virtual object Clone()
        {
            AppenderCollection newCol = new AppenderCollection(m_count);

            Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
            newCol.m_count   = m_count;
            newCol.m_version = m_version;

            return(newCol);
        }
コード例 #7
0
 /// <summary>
 /// Adds the elements of another <c>AppenderCollection</c> to the current <c>AppenderCollection</c>.
 /// </summary>
 /// <param name="x">The <c>AppenderCollection</c> whose elements should be added to the end of the current <c>AppenderCollection</c>.</param>
 /// <returns>The new <see cref="P:log4net.Appender.AppenderCollection.Count" /> of the <c>AppenderCollection</c>.</returns>
 public virtual int AddRange(AppenderCollection x)
 {
     if (m_count + x.Count >= m_array.Length)
     {
         EnsureCapacity(m_count + x.Count);
     }
     Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
     m_count += x.Count;
     m_version++;
     return(m_count);
 }
コード例 #8
0
 public virtual int AddRange(AppenderCollection x)
 {
     if ((this.m_count + x.Count) >= this.m_array.Length)
     {
         this.EnsureCapacity(this.m_count + x.Count);
     }
     Array.Copy(x.m_array, 0, this.m_array, this.m_count, x.Count);
     this.m_count += x.Count;
     this.m_version++;
     return(this.m_count);
 }
コード例 #9
0
		public void ToArrayTest()
		{
			AppenderCollection appenderCollection = new AppenderCollection();
			IAppender appender = new MemoryAppender();
			appenderCollection.Add(appender);

			IAppender[] appenderArray = appenderCollection.ToArray();

			Assert.AreEqual(1, appenderArray.Length);
			Assert.AreEqual(appender, appenderArray[0]);
		}
コード例 #10
0
		public void ReadOnlyToArrayTest()
		{
			AppenderCollection appenderCollection = new AppenderCollection();
			IAppender appender = new MemoryAppender();
			appenderCollection.Add(appender);
			AppenderCollection readonlyAppenderCollection = AppenderCollection.ReadOnly(appenderCollection);

			IAppender[] appenderArray = readonlyAppenderCollection.ToArray();

			Assert.AreEqual(1, appenderArray.Length);
			Assert.AreEqual(appender, appenderArray[0]);
		}
コード例 #11
0
ファイル: LogManager.cs プロジェクト: G-Understand/test
 private void ChangeLog4netLogFileName(log4net.ILog iLog, string fileName)
 {
     log4net.Core.LogImpl logImpl = iLog as log4net.Core.LogImpl;
     if (logImpl != null)
     {
         log4net.Appender.AppenderCollection ac = ((log4net.Repository.Hierarchy.Logger)logImpl.Logger).Appenders;
         for (int i = 0; i < ac.Count; i++)
         {     // 这里我只对RollingFileAppender类型做修改
             log4net.Appender.RollingFileAppender rfa = ac[i] as log4net.Appender.RollingFileAppender;
             if (rfa != null)
             {
                 rfa.File = fileName;
                 if (!System.IO.File.Exists(fileName))
                 {
                     System.IO.File.Create(fileName);
                 }
                 // 更新Writer属性
                 rfa.Writer = new  System.IO.StreamWriter(rfa.File, rfa.AppendToFile, rfa.Encoding);
             }
         }
     }
 }
コード例 #12
0
		/// <summary>
		/// Creates a shallow copy of the <see cref="AppenderCollection"/>.
		/// </summary>
		/// <returns>A new <see cref="AppenderCollection"/> with a shallow copy of the collection data.</returns>
		public virtual object Clone()
		{
			AppenderCollection newCol = new AppenderCollection(m_count);
			Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
			newCol.m_count = m_count;
			newCol.m_version = m_version;

			return newCol;
		}
コード例 #13
0
		/// <summary>
		/// Initializes a new instance of the <c>AppenderCollection</c> class
		/// that contains elements copied from the specified <c>AppenderCollection</c>.
		/// </summary>
		/// <param name="c">The <c>AppenderCollection</c> whose elements are copied to the new collection.</param>
		public AppenderCollection(AppenderCollection c)
		{
			m_array = new IAppender[c.Count];
			AddRange(c);
		}
コード例 #14
0
		/// <summary>
		/// Attaches an appender.
		/// </summary>
		/// <param name="newAppender">The appender to add.</param>
		/// <remarks>
		/// <para>
		/// If the appender is already in the list it won't be added again.
		/// </para>
		/// </remarks>
		public void AddAppender(IAppender newAppender) 
		{
			// Null values for newAppender parameter are strictly forbidden.
			if (newAppender == null)
			{
				throw new ArgumentNullException("newAppender");
			}
	
			m_appenderArray = null;
			if (m_appenderList == null) 
			{
				m_appenderList = new AppenderCollection(1);
			}
			if (!m_appenderList.Contains(newAppender))
			{
				m_appenderList.Add(newAppender);
			}
		}
コード例 #15
0
 public override int AddRange(AppenderCollection x)
 {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
コード例 #16
0
 internal ReadOnlyAppenderCollection(AppenderCollection list) : base(Tag.Default)
 {
     m_collection = list;
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <c>Enumerator</c> class.
 /// </summary>
 /// <param name="tc"></param>
 internal Enumerator(AppenderCollection tc)
 {
     m_collection = tc;
     m_index      = -1;
     m_version    = tc.m_version;
 }
コード例 #18
0
			public override int AddRange(AppenderCollection x)
			{
				lock(this.m_root)
					return m_collection.AddRange(x);
			}
コード例 #19
0
		/// <summary>
		/// Creates a synchronized (thread-safe) wrapper for a 
		/// <c>AppenderCollection</c> instance.
		/// </summary>
		/// <returns>
		/// An <c>AppenderCollection</c> wrapper that is synchronized (thread-safe).
		/// </returns>
		public static AppenderCollection Synchronized(AppenderCollection list)
		{
			if(list==null)
				throw new ArgumentNullException("list");
			return new SyncAppenderCollection(list);
		}
コード例 #20
0
			internal ReadOnlyAppenderCollection(AppenderCollection list) : base(Tag.Default)
			{
				m_collection = list;
			}
コード例 #21
0
		/// <summary>
		/// Adds the elements of another <c>AppenderCollection</c> to the current <c>AppenderCollection</c>.
		/// </summary>
		/// <param name="x">The <c>AppenderCollection</c> whose elements should be added to the end of the current <c>AppenderCollection</c>.</param>
		/// <returns>The new <see cref="AppenderCollection.Count"/> of the <c>AppenderCollection</c>.</returns>
		public virtual int AddRange(AppenderCollection x)
		{
			if (m_count + x.Count >= m_array.Length)
			{
				EnsureCapacity(m_count + x.Count);
			}
			
			Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
			m_count += x.Count;
			m_version++;

			return m_count;
		}
コード例 #22
0
 internal SyncAppenderCollection(AppenderCollection list) : base(Tag.Default)
 {
     m_root       = list.SyncRoot;
     m_collection = list;
 }
コード例 #23
0
 public override int AddRange(AppenderCollection x)
 {
     lock (this.m_root)
         return(m_collection.AddRange(x));
 }
コード例 #24
0
			/// <summary>
			/// Initializes a new instance of the <c>Enumerator</c> class.
			/// </summary>
			/// <param name="tc"></param>
			internal Enumerator(AppenderCollection tc)
			{
				m_collection = tc;
				m_index = -1;
				m_version = tc.m_version;
			}
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the <c>AppenderCollection</c> class
 /// that contains elements copied from the specified <c>AppenderCollection</c>.
 /// </summary>
 /// <param name="c">The <c>AppenderCollection</c> whose elements are copied to the new collection.</param>
 public AppenderCollection(AppenderCollection c)
 {
     m_array = new IAppender[c.Count];
     AddRange(c);
 }
コード例 #26
0
			public override int AddRange(AppenderCollection x)
			{
				throw new NotSupportedException("This is a Read Only Collection and can not be modified");
			}
コード例 #27
0
			internal SyncAppenderCollection(AppenderCollection list) : base(Tag.Default)
			{
				m_root = list.SyncRoot;
				m_collection = list;
			}