mscorlib(4.0.0.0) API with additions
SettingsPropertyValueCollection.cs
1 using System.Collections;
2 
3 namespace System.Configuration
4 {
7  {
8  private Hashtable _Indices;
9 
10  private ArrayList _Values;
11 
12  private bool _ReadOnly;
13 
17  public SettingsPropertyValue this[string name]
18  {
19  get
20  {
21  object obj = _Indices[name];
22  if (obj == null || !(obj is int))
23  {
24  return null;
25  }
26  int num = (int)obj;
27  if (num >= _Values.Count)
28  {
29  return null;
30  }
31  return (SettingsPropertyValue)_Values[num];
32  }
33  }
34 
37  public int Count => _Values.Count;
38 
42  public bool IsSynchronized => false;
43 
46  public object SyncRoot => this;
47 
50  {
52  _Values = new ArrayList();
53  }
54 
58  public void Add(SettingsPropertyValue property)
59  {
60  if (_ReadOnly)
61  {
62  throw new NotSupportedException();
63  }
64  int num = _Values.Add(property);
65  try
66  {
67  _Indices.Add(property.Name, num);
68  }
69  catch (Exception)
70  {
71  _Values.RemoveAt(num);
72  throw;
73  }
74  }
75 
79  public void Remove(string name)
80  {
81  if (_ReadOnly)
82  {
83  throw new NotSupportedException();
84  }
85  object obj = _Indices[name];
86  if (obj != null && obj is int)
87  {
88  int num = (int)obj;
89  if (num < _Values.Count)
90  {
91  _Values.RemoveAt(num);
92  _Indices.Remove(name);
93  ArrayList arrayList = new ArrayList();
94  foreach (DictionaryEntry index in _Indices)
95  {
96  if ((int)index.Value > num)
97  {
98  arrayList.Add(index.Key);
99  }
100  }
101  foreach (string item in arrayList)
102  {
103  _Indices[item] = (int)_Indices[item] - 1;
104  }
105  }
106  }
107  }
108 
112  {
113  return _Values.GetEnumerator();
114  }
115 
118  public object Clone()
119  {
120  return new SettingsPropertyValueCollection(_Indices, _Values);
121  }
122 
124  public void SetReadOnly()
125  {
126  if (!_ReadOnly)
127  {
128  _ReadOnly = true;
129  _Values = ArrayList.ReadOnly(_Values);
130  }
131  }
132 
134  public void Clear()
135  {
136  _Values.Clear();
137  _Indices.Clear();
138  }
139 
143  public void CopyTo(Array array, int index)
144  {
145  _Values.CopyTo(array, index);
146  }
147 
148  private SettingsPropertyValueCollection(Hashtable indices, ArrayList values)
149  {
150  _Indices = (Hashtable)indices.Clone();
151  _Values = (ArrayList)values.Clone();
152  }
153  }
154 }
virtual void Add(object key, object value)
Adds an element with the specified key and value into the T:System.Collections.Hashtable.
Definition: Hashtable.cs:916
object SyncRoot
Gets the object to synchronize access to the collection.
bool IsSynchronized
Gets a value that indicates whether access to the collection is synchronized (thread safe).
virtual void RemoveAt(int index)
Removes the element at the specified index of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2847
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2255
int Count
Gets a value that specifies the number of T:System.Configuration.SettingsPropertyValue objects in the...
Definition: __Canon.cs:3
virtual object Clone()
Creates a shallow copy of the T:System.Collections.Hashtable.
Definition: Hashtable.cs:946
object Clone()
Creates a copy of the existing collection.
Contains a collection of settings property values that map T:System.Configuration....
virtual void Clear()
Removes all elements from the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2461
virtual object Clone()
Creates a shallow copy of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2473
void Clear()
Removes all T:System.Configuration.SettingsPropertyValue objects from the collection.
void CopyTo(Array array, int index)
Copies this T:System.Configuration.SettingsPropertyValueCollection collection to an array.
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
void Remove(string name)
Removes a T:System.Configuration.SettingsPropertyValue object from the collection.
Supports cloning, which creates a new instance of a class with the same value as an existing instance...
Definition: ICloneable.cs:7
void Add(SettingsPropertyValue property)
Adds a T:System.Configuration.SettingsPropertyValue object to the collection.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition: Array.cs:17
virtual void CopyTo(Array array)
Copies the entire T:System.Collections.ArrayList to a compatible one-dimensional T:System....
Definition: ArrayList.cs:2516
Contains the value of a settings property that can be loaded and stored by an instance of T:System....
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
Definition: ArrayList.cs:2381
IEnumerator GetEnumerator()
Gets the T:System.Collections.IEnumerator object as it applies to the collection.
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
Definition: Exception.cs:22
virtual void Remove(object key)
Removes the element with the specified key from the T:System.Collections.Hashtable.
Definition: Hashtable.cs:1349
virtual IEnumerator GetEnumerator()
Returns an enumerator for the entire T:System.Collections.ArrayList.
Definition: ArrayList.cs:2615
static StringComparer CurrentCultureIgnoreCase
Gets a T:System.StringComparer object that performs case-insensitive string comparisons using the wor...
string Name
Gets the name of the property from the associated T:System.Configuration.SettingsProperty object.
virtual void Clear()
Removes all elements from the T:System.Collections.Hashtable.
Definition: Hashtable.cs:924
The exception that is thrown when an invoked method is not supported, or when there is an attempt to ...
Defines size, enumerators, and synchronization methods for all nongeneric collections.
Definition: ICollection.cs:8
Defines a dictionary key/value pair that can be set or retrieved.
static IList ReadOnly(IList list)
Returns a read-only T:System.Collections.IList wrapper.
Definition: ArrayList.cs:2806
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...
SettingsPropertyValueCollection()
Initializes a new instance of the T:System.Configuration.SettingsPropertyValueCollection class.
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Definition: ArrayList.cs:14