Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TraceListenerCollection.cs
Go to the documentation of this file.
3
4namespace System.Diagnostics;
5
7{
8 private readonly List<TraceListener> _list;
9
10 public TraceListener this[int i]
11 {
12 get
13 {
14 return _list[i];
15 }
16 set
17 {
19 _list[i] = value;
20 }
21 }
22
23 public TraceListener? this[string name]
24 {
25 get
26 {
28 try
29 {
30 while (enumerator.MoveNext())
31 {
33 if (traceListener.Name == name)
34 {
35 return traceListener;
36 }
37 }
38 }
39 finally
40 {
42 if (disposable != null)
43 {
44 disposable.Dispose();
45 }
46 }
47 return null;
48 }
49 }
50
51 public int Count => _list.Count;
52
53 object? IList.this[int index]
54 {
55 get
56 {
57 return _list[index];
58 }
59 set
60 {
62 {
63 throw new ArgumentException(System.SR.MustAddListener, "value");
64 }
67 }
68 }
69
70 bool IList.IsReadOnly => false;
71
72 bool IList.IsFixedSize => false;
73
74 object ICollection.SyncRoot => this;
75
76 bool ICollection.IsSynchronized => true;
77
79 {
81 }
82
83 public int Add(TraceListener listener)
84 {
85 InitializeListener(listener);
87 {
88 return ((IList)_list).Add((object?)listener);
89 }
90 }
91
93 {
94 if (value == null)
95 {
96 throw new ArgumentNullException("value");
97 }
98 for (int i = 0; i < value.Length; i++)
99 {
100 Add(value[i]);
101 }
102 }
103
105 {
106 if (value == null)
107 {
108 throw new ArgumentNullException("value");
109 }
110 int count = value.Count;
111 for (int i = 0; i < count; i++)
112 {
113 Add(value[i]);
114 }
115 }
116
117 public void Clear()
118 {
119 _list.Clear();
120 }
121
122 public bool Contains(TraceListener? listener)
123 {
124 return ((IList)this).Contains((object?)listener);
125 }
126
128 {
130 }
131
133 {
134 return _list.GetEnumerator();
135 }
136
137 internal void InitializeListener(TraceListener listener)
138 {
139 if (listener == null)
140 {
141 throw new ArgumentNullException("listener");
142 }
143 listener.IndentSize = TraceInternal.IndentSize;
144 listener.IndentLevel = TraceInternal.IndentLevel;
145 }
146
147 public int IndexOf(TraceListener? listener)
148 {
149 return ((IList)this).IndexOf((object?)listener);
150 }
151
152 public void Insert(int index, TraceListener listener)
153 {
154 InitializeListener(listener);
156 {
157 _list.Insert(index, listener);
158 }
159 }
160
161 public void Remove(TraceListener? listener)
162 {
163 ((IList)this).Remove((object?)listener);
164 }
165
166 public void Remove(string name)
167 {
168 TraceListener traceListener = this[name];
169 if (traceListener != null)
170 {
171 ((IList)this).Remove((object?)traceListener);
172 }
173 }
174
175 public void RemoveAt(int index)
176 {
178 {
179 _list.RemoveAt(index);
180 }
181 }
182
183 int IList.Add(object value)
184 {
185 if (!(value is TraceListener listener))
186 {
187 throw new ArgumentException(System.SR.MustAddListener, "value");
188 }
189 InitializeListener(listener);
191 {
192 return ((IList)_list).Add(value);
193 }
194 }
195
196 bool IList.Contains(object value)
197 {
199 }
200
201 int IList.IndexOf(object value)
202 {
203 return _list.IndexOf((TraceListener)value);
204 }
205
206 void IList.Insert(int index, object value)
207 {
208 if (!(value is TraceListener listener))
209 {
210 throw new ArgumentException(System.SR.MustAddListener, "value");
211 }
212 InitializeListener(listener);
214 {
215 _list.Insert(index, (TraceListener)value);
216 }
217 }
218
219 void IList.Remove(object value)
220 {
222 {
224 }
225 }
226
231}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static readonly object critSec
void CopyTo(TraceListener[] listeners, int index)
void Insert(int index, TraceListener listener)
void AddRange(TraceListenerCollection value)
static string MustAddListener
Definition SR.cs:16
Definition SR.cs:7
void CopyTo(T[] array, int arrayIndex)
void Insert(int index, T item)