jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
#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;
 
namespace log4net.Core
{
    /// <summary>
    /// A strongly-typed collection of <see cref="Level"/> objects.
    /// </summary>
    /// <author>Nicko Cadell</author>
    public class LevelCollection : ICollection, IList, IEnumerable, ICloneable
    {
        #region Interfaces
 
        /// <summary>
        /// Supports type-safe iteration over a <see cref="LevelCollection"/>.
        /// </summary>
        public interface ILevelCollectionEnumerator
        {
            /// <summary>
            /// Gets the current element in the collection.
            /// </summary>
            Level Current { get; }
 
            /// <summary>
            /// Advances the enumerator to the next element in the collection.
            /// </summary>
            /// <returns>
            /// <c>true</c> if the enumerator was successfully advanced to the next element; 
            /// <c>false</c> if the enumerator has passed the end of the collection.
            /// </returns>
            /// <exception cref="InvalidOperationException">
            /// The collection was modified after the enumerator was created.
            /// </exception>
            bool MoveNext();
 
            /// <summary>
            /// Sets the enumerator to its initial position, before the first element in the collection.
            /// </summary>
            void Reset();
        }
 
        #endregion
 
        private const int DEFAULT_CAPACITY = 16;
 
        #region Implementation (data)
 
        private Level[] m_array;
        private int m_count = 0;
        private int m_version = 0;
 
        #endregion
    
        #region Static Wrappers
 
        /// <summary>
        /// Creates a read-only wrapper for a <c>LevelCollection</c> instance.
        /// </summary>
        /// <param name="list">list to create a readonly wrapper arround</param>
        /// <returns>
        /// A <c>LevelCollection</c> wrapper that is read-only.
        /// </returns>
        public static LevelCollection ReadOnly(LevelCollection list)
        {
            if(list==null) throw new ArgumentNullException("list");
 
            return new ReadOnlyLevelCollection(list);
        }
 
        #endregion
 
        #region Constructors
 
        /// <summary>
        /// Initializes a new instance of the <c>LevelCollection</c> class
        /// that is empty and has the default initial capacity.
        /// </summary>
        public LevelCollection()
        {
            m_array = new Level[DEFAULT_CAPACITY];
        }
        
        /// <summary>
        /// Initializes a new instance of the <c>LevelCollection</c> class
        /// that has the specified initial capacity.
        /// </summary>
        /// <param name="capacity">
        /// The number of elements that the new <c>LevelCollection</c> is initially capable of storing.
        /// </param>
        public LevelCollection(int capacity)
        {
            m_array = new Level[capacity];
        }
 
        /// <summary>
        /// Initializes a new instance of the <c>LevelCollection</c> class
        /// that contains elements copied from the specified <c>LevelCollection</c>.
        /// </summary>
        /// <param name="c">The <c>LevelCollection</c> whose elements are copied to the new collection.</param>
        public LevelCollection(LevelCollection c)
        {
            m_array = new Level[c.Count];
            AddRange(c);
        }
 
        /// <summary>
        /// Initializes a new instance of the <c>LevelCollection</c> class
        /// that contains elements copied from the specified <see cref="Level"/> array.
        /// </summary>
        /// <param name="a">The <see cref="Level"/> array whose elements are copied to the new list.</param>
        public LevelCollection(Level[] a)
        {
            m_array = new Level[a.Length];
            AddRange(a);
        }
 
        /// <summary>
        /// Initializes a new instance of the <c>LevelCollection</c> class
        /// that contains elements copied from the specified <see cref="Level"/> collection.
        /// </summary>
        /// <param name="col">The <see cref="Level"/> collection whose elements are copied to the new list.</param>
        public LevelCollection(ICollection col)
        {
            m_array = new Level[col.Count];
            AddRange(col);
        }
        
        /// <summary>
        /// Type visible only to our subclasses
        /// Used to access protected constructor
        /// </summary>
        protected internal enum Tag 
        {
            /// <summary>
            /// A value
            /// </summary>
            Default
        }
 
        /// <summary>
        /// Allow subclasses to avoid our default constructors
        /// </summary>
        /// <param name="tag"></param>
        protected internal LevelCollection(Tag tag)
        {
            m_array = null;
        }
        #endregion
        
        #region Operations (type-safe ICollection)
 
        /// <summary>
        /// Gets the number of elements actually contained in the <c>LevelCollection</c>.
        /// </summary>
        public virtual int Count
        {
            get { return m_count; }
        }
 
        /// <summary>
        /// Copies the entire <c>LevelCollection</c> to a one-dimensional
        /// <see cref="Level"/> array.
        /// </summary>
        /// <param name="array">The one-dimensional <see cref="Level"/> array to copy to.</param>
        public virtual void CopyTo(Level[] array)
        {
            this.CopyTo(array, 0);
        }
 
        /// <summary>
        /// Copies the entire <c>LevelCollection</c> to a one-dimensional
        /// <see cref="Level"/> array, starting at the specified index of the target array.
        /// </summary>
        /// <param name="array">The one-dimensional <see cref="Level"/> array to copy to.</param>
        /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
        public virtual void CopyTo(Level[] array, int start)
        {
            if (m_count > array.GetUpperBound(0) + 1 - start)
            {
                throw new System.ArgumentException("Destination array was not long enough.");
            }
            
            Array.Copy(m_array, 0, array, start, m_count); 
        }
 
        /// <summary>
        /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
        /// </summary>
        /// <value>true if access to the ICollection is synchronized (thread-safe); otherwise, false.</value>
        public virtual bool IsSynchronized
        {
            get { return m_array.IsSynchronized; }
        }
 
        /// <summary>
        /// Gets an object that can be used to synchronize access to the collection.
        /// </summary>
        public virtual object SyncRoot
        {
            get { return m_array.SyncRoot; }
        }
 
        #endregion
        
        #region Operations (type-safe IList)
 
        /// <summary>
        /// Gets or sets the <see cref="Level"/> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the element to get or set.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="index"/> is less than zero</para>
        /// <para>-or-</para>
        /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
        /// </exception>
        public virtual Level this[int index]
        {
            get
            {
                ValidateIndex(index); // throws
                return m_array[index]; 
            }
            set
            {
                ValidateIndex(index); // throws
                ++m_version; 
                m_array[index] = value; 
            }
        }
 
        /// <summary>
        /// Adds a <see cref="Level"/> to the end of the <c>LevelCollection</c>.
        /// </summary>
        /// <param name="item">The <see cref="Level"/> to be added to the end of the <c>LevelCollection</c>.</param>
        /// <returns>The index at which the value has been added.</returns>
        public virtual int Add(Level item)
        {
            if (m_count == m_array.Length)
            {
                EnsureCapacity(m_count + 1);
            }
 
            m_array[m_count] = item;
            m_version++;
 
            return m_count++;
        }
        
        /// <summary>
        /// Removes all elements from the <c>LevelCollection</c>.
        /// </summary>
        public virtual void Clear()
        {
            ++m_version;
            m_array = new Level[DEFAULT_CAPACITY];
            m_count = 0;
        }
        
        /// <summary>
        /// Creates a shallow copy of the <see cref="LevelCollection"/>.
        /// </summary>
        /// <returns>A new <see cref="LevelCollection"/> with a shallow copy of the collection data.</returns>
        public virtual object Clone()
        {
            LevelCollection newCol = new LevelCollection(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;
        }
 
        /// <summary>
        /// Determines whether a given <see cref="Level"/> is in the <c>LevelCollection</c>.
        /// </summary>
        /// <param name="item">The <see cref="Level"/> to check for.</param>
        /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>LevelCollection</c>; otherwise, <c>false</c>.</returns>
        public virtual bool Contains(Level item)
        {
            for (int i=0; i != m_count; ++i)
            {
                if (m_array[i].Equals(item))
                {
                    return true;
                }
            }
            return false;
        }
 
        /// <summary>
        /// Returns the zero-based index of the first occurrence of a <see cref="Level"/>
        /// in the <c>LevelCollection</c>.
        /// </summary>
        /// <param name="item">The <see cref="Level"/> to locate in the <c>LevelCollection</c>.</param>
        /// <returns>
        /// The zero-based index of the first occurrence of <paramref name="item"/> 
        /// in the entire <c>LevelCollection</c>, if found; otherwise, -1.
        ///    </returns>
        public virtual int IndexOf(Level item)
        {
            for (int i=0; i != m_count; ++i)
            {
                if (m_array[i].Equals(item))
                {
                    return i;
                }
            }
            return -1;
        }
 
        /// <summary>
        /// Inserts an element into the <c>LevelCollection</c> at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
        /// <param name="item">The <see cref="Level"/> to insert.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="index"/> is less than zero</para>
        /// <para>-or-</para>
        /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
        /// </exception>
        public virtual void Insert(int index, Level item)
        {
            ValidateIndex(index, true); // throws
            
            if (m_count == m_array.Length)
            {
                EnsureCapacity(m_count + 1);
            }
 
            if (index < m_count)
            {
                Array.Copy(m_array, index, m_array, index + 1, m_count - index);
            }
 
            m_array[index] = item;
            m_count++;
            m_version++;
        }
 
        /// <summary>
        /// Removes the first occurrence of a specific <see cref="Level"/> from the <c>LevelCollection</c>.
        /// </summary>
        /// <param name="item">The <see cref="Level"/> to remove from the <c>LevelCollection</c>.</param>
        /// <exception cref="ArgumentException">
        /// The specified <see cref="Level"/> was not found in the <c>LevelCollection</c>.
        /// </exception>
        public virtual void Remove(Level item)
        {           
            int i = IndexOf(item);
            if (i < 0)
            {
                throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
            }
            
            ++m_version;
            RemoveAt(i);
        }
 
        /// <summary>
        /// Removes the element at the specified index of the <c>LevelCollection</c>.
        /// </summary>
        /// <param name="index">The zero-based index of the element to remove.</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="index"/> is less than zero</para>
        /// <para>-or-</para>
        /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
        /// </exception>
        public virtual void RemoveAt(int index)
        {
            ValidateIndex(index); // throws
            
            m_count--;
 
            if (index < m_count)
            {
                Array.Copy(m_array, index + 1, m_array, index, m_count - index);
            }
            
            // We can't set the deleted entry equal to null, because it might be a value type.
            // Instead, we'll create an empty single-element array of the right type and copy it 
            // over the entry we want to erase.
            Level[] temp = new Level[1];
            Array.Copy(temp, 0, m_array, m_count, 1);
            m_version++;
        }
 
        /// <summary>
        /// Gets a value indicating whether the collection has a fixed size.
        /// </summary>
        /// <value>true if the collection has a fixed size; otherwise, false. The default is false</value>
        public virtual bool IsFixedSize
        {
            get { return false; }
        }
 
        /// <summary>
        /// Gets a value indicating whether the IList is read-only.
        /// </summary>
        /// <value>true if the collection is read-only; otherwise, false. The default is false</value>
        public virtual bool IsReadOnly
        {
            get { return false; }
        }
 
        #endregion
 
        #region Operations (type-safe IEnumerable)
        
        /// <summary>
        /// Returns an enumerator that can iterate through the <c>LevelCollection</c>.
        /// </summary>
        /// <returns>An <see cref="Enumerator"/> for the entire <c>LevelCollection</c>.</returns>
        public virtual ILevelCollectionEnumerator GetEnumerator()
        {
            return new Enumerator(this);
        }
 
        #endregion
 
        #region Public helpers (just to mimic some nice features of ArrayList)
        
        /// <summary>
        /// Gets or sets the number of elements the <c>LevelCollection</c> can contain.
        /// </summary>
        public virtual int Capacity
        {
            get 
            { 
                return m_array.Length; 
            }
            set
            {
                if (value < m_count)
                {
                    value = m_count;
                }
 
                if (value != m_array.Length)
                {
                    if (value > 0)
                    {
                        Level[] temp = new Level[value];
                        Array.Copy(m_array, 0, temp, 0, m_count);
                        m_array = temp;
                    }
                    else
                    {
                        m_array = new Level[DEFAULT_CAPACITY];
                    }
                }
            }
        }
 
        /// <summary>
        /// Adds the elements of another <c>LevelCollection</c> to the current <c>LevelCollection</c>.
        /// </summary>
        /// <param name="x">The <c>LevelCollection</c> whose elements should be added to the end of the current <c>LevelCollection</c>.</param>
        /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
        public virtual int AddRange(LevelCollection 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;
        }
 
        /// <summary>
        /// Adds the elements of a <see cref="Level"/> array to the current <c>LevelCollection</c>.
        /// </summary>
        /// <param name="x">The <see cref="Level"/> array whose elements should be added to the end of the <c>LevelCollection</c>.</param>
        /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
        public virtual int AddRange(Level[] x)
        {
            if (m_count + x.Length >= m_array.Length)
            {
                EnsureCapacity(m_count + x.Length);
            }
 
            Array.Copy(x, 0, m_array, m_count, x.Length);
            m_count += x.Length;
            m_version++;
 
            return m_count;
        }
 
        /// <summary>
        /// Adds the elements of a <see cref="Level"/> collection to the current <c>LevelCollection</c>.
        /// </summary>
        /// <param name="col">The <see cref="Level"/> collection whose elements should be added to the end of the <c>LevelCollection</c>.</param>
        /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
        public virtual int AddRange(ICollection col)
        {
            if (m_count + col.Count >= m_array.Length)
            {
                EnsureCapacity(m_count + col.Count);
            }
 
            foreach(object item in col)
            {
                Add((Level)item);
            }
 
            return m_count;
        }
        
        /// <summary>
        /// Sets the capacity to the actual number of elements.
        /// </summary>
        public virtual void TrimToSize()
        {
            this.Capacity = m_count;
        }
 
        #endregion
 
        #region Implementation (helpers)
 
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="i"/> is less than zero</para>
        /// <para>-or-</para>
        /// <para><paramref name="i"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
        /// </exception>
        private void ValidateIndex(int i)
        {
            ValidateIndex(i, false);
        }
 
        /// <exception cref="ArgumentOutOfRangeException">
        /// <para><paramref name="i"/> is less than zero</para>
        /// <para>-or-</para>
        /// <para><paramref name="i"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
        /// </exception>
        private void ValidateIndex(int i, bool allowEqualEnd)
        {
            int max = (allowEqualEnd) ? (m_count) : (m_count-1);
            if (i < 0 || i > max)
            {
                throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
            }
        }
 
        private void EnsureCapacity(int min)
        {
            int newCapacity = ((m_array.Length == 0) ? DEFAULT_CAPACITY : m_array.Length * 2);
            if (newCapacity < min)
            {
                newCapacity = min;
            }
 
            this.Capacity = newCapacity;
        }
 
        #endregion
        
        #region Implementation (ICollection)
 
        void ICollection.CopyTo(Array array, int start)
        {
            Array.Copy(m_array, 0, array, start, m_count);
        }
 
        #endregion
 
        #region Implementation (IList)
 
        object IList.this[int i]
        {
            get { return (object)this[i]; }
            set { this[i] = (Level)value; }
        }
 
        int IList.Add(object x)
        {
            return this.Add((Level)x);
        }
 
        bool IList.Contains(object x)
        {
            return this.Contains((Level)x);
        }
 
        int IList.IndexOf(object x)
        {
            return this.IndexOf((Level)x);
        }
 
        void IList.Insert(int pos, object x)
        {
            this.Insert(pos, (Level)x);
        }
 
        void IList.Remove(object x)
        {
            this.Remove((Level)x);
        }
 
        void IList.RemoveAt(int pos)
        {
            this.RemoveAt(pos);
        }
 
        #endregion
 
        #region Implementation (IEnumerable)
 
        IEnumerator IEnumerable.GetEnumerator()
        {
            return (IEnumerator)(this.GetEnumerator());
        }
 
        #endregion
 
        #region Nested enumerator class
 
        /// <summary>
        /// Supports simple iteration over a <see cref="LevelCollection"/>.
        /// </summary>
        private sealed class Enumerator : IEnumerator, ILevelCollectionEnumerator
        {
            #region Implementation (data)
            
            private readonly LevelCollection m_collection;
            private int m_index;
            private int m_version;
            
            #endregion
        
            #region Construction
            
            /// <summary>
            /// Initializes a new instance of the <c>Enumerator</c> class.
            /// </summary>
            /// <param name="tc"></param>
            internal Enumerator(LevelCollection tc)
            {
                m_collection = tc;
                m_index = -1;
                m_version = tc.m_version;
            }
            
            #endregion
    
            #region Operations (type-safe IEnumerator)
            
            /// <summary>
            /// Gets the current element in the collection.
            /// </summary>
            public Level Current
            {
                get { return m_collection[m_index]; }
            }
 
            /// <summary>
            /// Advances the enumerator to the next element in the collection.
            /// </summary>
            /// <returns>
            /// <c>true</c> if the enumerator was successfully advanced to the next element; 
            /// <c>false</c> if the enumerator has passed the end of the collection.
            /// </returns>
            /// <exception cref="InvalidOperationException">
            /// The collection was modified after the enumerator was created.
            /// </exception>
            public bool MoveNext()
            {
                if (m_version != m_collection.m_version)
                {
                    throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
                }
 
                ++m_index;
                return (m_index < m_collection.Count);
            }
 
            /// <summary>
            /// Sets the enumerator to its initial position, before the first element in the collection.
            /// </summary>
            public void Reset()
            {
                m_index = -1;
            }
 
            #endregion
    
            #region Implementation (IEnumerator)
            
            object IEnumerator.Current
            {
                get { return this.Current; }
            }
            
            #endregion
        }
 
        #endregion
 
        #region Nested Read Only Wrapper class
 
        private sealed class ReadOnlyLevelCollection : LevelCollection
        {
            #region Implementation (data)
 
            private readonly LevelCollection m_collection;
 
            #endregion
 
            #region Construction
 
            internal ReadOnlyLevelCollection(LevelCollection list) : base(Tag.Default)
            {
                m_collection = list;
            }
 
            #endregion
 
            #region Type-safe ICollection
 
            public override void CopyTo(Level[] array)
            {
                m_collection.CopyTo(array);
            }
 
            public override void CopyTo(Level[] array, int start)
            {
                m_collection.CopyTo(array,start);
            }
            public override int Count
            {
                get { return m_collection.Count; }
            }
 
            public override bool IsSynchronized
            {
                get { return m_collection.IsSynchronized; }
            }
 
            public override object SyncRoot
            {
                get { return this.m_collection.SyncRoot; }
            }
 
            #endregion
 
            #region Type-safe IList
 
            public override Level this[int i]
            {
                get { return m_collection[i]; }
                set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
            }
 
            public override int Add(Level x)
            {
                throw new NotSupportedException("This is a Read Only Collection and can not be modified");
            }
 
            public override void Clear()
            {
                throw new NotSupportedException("This is a Read Only Collection and can not be modified");
            }
 
            public override bool Contains(Level x)
            {
                return m_collection.Contains(x);
            }
 
            public override int IndexOf(Level x)
            {
                return m_collection.IndexOf(x);
            }
 
            public override void Insert(int pos, Level x)
            {
                throw new NotSupportedException("This is a Read Only Collection and can not be modified");
            }
 
            public override void Remove(Level x)
            {           
                throw new NotSupportedException("This is a Read Only Collection and can not be modified");
            }
 
            public override void RemoveAt(int pos)
            {
                throw new NotSupportedException("This is a Read Only Collection and can not be modified");
            }
 
            public override bool IsFixedSize
            {
                get { return true; }
            }
 
            public override bool IsReadOnly
            {
                get { return true; }
            }
 
            #endregion
 
            #region Type-safe IEnumerable
 
            public override ILevelCollectionEnumerator GetEnumerator()
            {
                return m_collection.GetEnumerator();
            }
 
            #endregion
 
            #region Public Helpers
 
            // (just to mimic some nice features of ArrayList)
            public override int Capacity
            {
                get { return m_collection.Capacity; }
                set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
            }
 
            public override int AddRange(LevelCollection x)
            {
                throw new NotSupportedException("This is a Read Only Collection and can not be modified");
            }
 
            public override int AddRange(Level[] x)
            {
                throw new NotSupportedException("This is a Read Only Collection and can not be modified");
            }
 
            #endregion
        }
 
        #endregion
    }
 
}