mscorlib(4.0.0.0) API with additions
CodeNamespaceImportCollection.cs
1 using System.Collections;
3 
4 namespace System.CodeDom
5 {
8  [ClassInterface(ClassInterfaceType.AutoDispatch)]
9  [ComVisible(true)]
11  {
12  private ArrayList data = new ArrayList();
13 
15 
20  public CodeNamespaceImport this[int index]
21  {
22  get
23  {
24  return (CodeNamespaceImport)data[index];
25  }
26  set
27  {
28  data[index] = value;
29  SyncKeys();
30  }
31  }
32 
35  public int Count => data.Count;
36 
40  bool IList.IsReadOnly
41  {
42  get
43  {
44  return false;
45  }
46  }
47 
51  bool IList.IsFixedSize
52  {
53  get
54  {
55  return false;
56  }
57  }
58 
62  object IList.this[int index]
63  {
64  get
65  {
66  return this[index];
67  }
68  set
69  {
70  this[index] = (CodeNamespaceImport)value;
71  SyncKeys();
72  }
73  }
74 
77  int ICollection.Count
78  {
79  get
80  {
81  return Count;
82  }
83  }
84 
89  {
90  get
91  {
92  return false;
93  }
94  }
95 
98  object ICollection.SyncRoot
99  {
100  get
101  {
102  return null;
103  }
104  }
105 
108  public void Add(CodeNamespaceImport value)
109  {
110  if (!keys.ContainsKey(value.Namespace))
111  {
112  keys[value.Namespace] = value;
113  data.Add(value);
114  }
115  }
116 
121  public void AddRange(CodeNamespaceImport[] value)
122  {
123  if (value == null)
124  {
125  throw new ArgumentNullException("value");
126  }
127  foreach (CodeNamespaceImport value2 in value)
128  {
129  Add(value2);
130  }
131  }
132 
134  public void Clear()
135  {
136  data.Clear();
137  keys.Clear();
138  }
139 
140  private void SyncKeys()
141  {
143  IEnumerator enumerator = GetEnumerator();
144  try
145  {
146  while (enumerator.MoveNext())
147  {
148  CodeNamespaceImport codeNamespaceImport = (CodeNamespaceImport)enumerator.Current;
149  keys[codeNamespaceImport.Namespace] = codeNamespaceImport;
150  }
151  }
152  finally
153  {
154  IDisposable disposable = enumerator as IDisposable;
155  if (disposable != null)
156  {
157  disposable.Dispose();
158  }
159  }
160  }
161 
165  {
166  return data.GetEnumerator();
167  }
168 
172  void ICollection.CopyTo(Array array, int index)
173  {
174  data.CopyTo(array, index);
175  }
176 
180  {
181  return GetEnumerator();
182  }
183 
187  int IList.Add(object value)
188  {
189  return data.Add((CodeNamespaceImport)value);
190  }
191 
193  void IList.Clear()
194  {
195  Clear();
196  }
197 
202  bool IList.Contains(object value)
203  {
204  return data.Contains(value);
205  }
206 
210  int IList.IndexOf(object value)
211  {
212  return data.IndexOf((CodeNamespaceImport)value);
213  }
214 
218  void IList.Insert(int index, object value)
219  {
220  data.Insert(index, (CodeNamespaceImport)value);
221  SyncKeys();
222  }
223 
226  void IList.Remove(object value)
227  {
228  data.Remove((CodeNamespaceImport)value);
229  SyncKeys();
230  }
231 
234  void IList.RemoveAt(int index)
235  {
236  data.RemoveAt(index);
237  SyncKeys();
238  }
239  }
240 }
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
Definition: ICollection.cs:23
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
bool MoveNext()
Advances the enumerator to the next element of the collection.
IEnumerator GetEnumerator()
Gets an enumerator that enumerates the collection members.
int Count
Gets the number of namespaces in the collection.
Represents a non-generic collection of objects that can be individually accessed by index.
Definition: IList.cs:8
void RemoveAt(int index)
Removes the T:System.Collections.IList item at the specified index.
void Insert(int index, object value)
Inserts an item to the T:System.Collections.IList at the specified index.
Represents a namespace import directive that indicates a namespace to use.
Definition: __Canon.cs:3
bool IsReadOnly
Gets a value indicating whether the T:System.Collections.IList is read-only.
Definition: IList.cs:30
void Add(CodeNamespaceImport value)
Adds a T:System.CodeDom.CodeNamespaceImport object to the collection.
void Clear()
Removes all items from the T:System.Collections.IList.
int IndexOf(object value)
Determines the index of a specific item in the T:System.Collections.IList.
virtual bool ContainsKey(object key)
Determines whether the T:System.Collections.Hashtable contains a specific key.
Definition: Hashtable.cs:983
bool IsFixedSize
Gets a value indicating whether the T:System.Collections.IList has a fixed size.
Definition: IList.cs:40
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
Definition: IEnumerable.cs:9
Represents a collection of key/value pairs that are organized based on the hash code of the key....
Definition: Hashtable.cs:17
Represents a collection of T:System.CodeDom.CodeNamespaceImport objects.
object Current
Gets the element in the collection at the current position of the enumerator.
Definition: IEnumerator.cs:15
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
Definition: ICollection.cs:33
int Add(object value)
Adds an item to the T:System.Collections.IList.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
void AddRange(CodeNamespaceImport[] value)
Adds a set of T:System.CodeDom.CodeNamespaceImport objects to the collection.
Specifies that the class can be serialized.
static StringComparer OrdinalIgnoreCase
Gets a T:System.StringComparer object that performs a case-insensitive ordinal string comparison.
void Remove(object value)
Removes the first occurrence of a specific object from the T:System.Collections.IList.
ClassInterfaceType
Identifies the type of class interface that is generated for a class.
bool Contains(object value)
Determines whether the T:System.Collections.IList contains a specific value.
virtual void Clear()
Removes all elements from the T:System.Collections.Hashtable.
Definition: Hashtable.cs:924
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
Definition: ICollection.cs:14
Defines size, enumerators, and synchronization methods for all nongeneric collections.
Definition: ICollection.cs:8
string Namespace
Gets or sets the namespace to import.
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
Supports a simple iteration over a non-generic collection.
Definition: IEnumerator.cs:9
Represents a string comparison operation that uses specific case and culture-based or ordinal compari...
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14