Пример #1
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));
        }
Пример #2
0
        /// <summary>
        /// 创建一个集合<see cref="AppenderCollection"/>的浅拷贝.
        /// </summary>
        /// <returns>一个新的集合来自<see cref="AppenderCollection"/>的浅拷贝.</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);
        }
Пример #3
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);
        }
Пример #4
0
        /// <summary>
        /// 附加一个附加器.
        /// </summary>
        /// <param name="newAppender">要附加的附加器.</param>
        /// <remarks>
        /// <para>
        /// 如果存在则不再添加.
        /// </para>
        /// </remarks>
        public void AddAppender(IAppender newAppender)
        {
            if (newAppender == null)
            {
                throw new ArgumentNullException("没有附加器");
            }

            m_appenderArray = null;
            if (m_appenderList == null)
            {
                m_appenderList = new AppenderCollection(1);
            }

            if (!m_appenderList.Contains(newAppender))
            {
                m_appenderList.Add(newAppender);
            }
        }
Пример #5
0
 /// <summary>
 /// 关闭内嵌的附加器.
 /// </summary>
 public void CloseNestedAppenders()
 {
     m_appenderLock.AcquireWriterLock(100);
     try
     {
         if (m_appenderAttachedImpl != null)
         {
             AppenderCollection appenders = m_appenderAttachedImpl.Appenders;
             foreach (IAppender appender in appenders)
             {
                 if (appender is IAppenderAttachable)
                 {
                     appender.Close();
                 }
             }
         }
     }
     finally
     {
         m_appenderLock.ReleaseWriterLock();
     }
 }
Пример #6
0
 public override int AddRange(AppenderCollection x)
 {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
Пример #7
0
 internal ReadOnlyAppenderCollection(AppenderCollection list)
     : base(Tag.Default)
 {
     m_collection = list;
 }
Пример #8
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;
 }
Пример #9
0
 /// <summary>
 /// 初始化IAppender数组,使用AppenderCollection集合.
 /// </summary>
 /// <param name="c"></param>
 public AppenderCollection(AppenderCollection c)
 {
     m_array = new IAppender[c.Count];
     AddRange(c);
 }