[Serializable] |
This implementation does not provide a synchronized (thread-safe) wrapper for a NameObjectCollectionBase, but derived classes can create their own synchronized versions of the NameObjectCollectionBase using the NameObjectCollectionBase.System.Collections.ICollection.SyncRoot property.
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
The capacity is the number of key-and-value pairs that the NameObjectCollectionBase instance can contain. The default initial capacity is zero. The capacity is automatically increased as required.
The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. The default hash code provider is the CaseInsensitiveHashCodeProvider.
The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.
null is allowed as a key or as a value.
The NameObjectCollectionBase.BaseGet method does not distinguish between null which is returned because the specified key is not found and null which is returned because the value associated with the key is null.Count | Read-only Gets the number of key-and-value pairs contained in the NameObjectCollectionBase instance. |
Keys | Read-only Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetEnumerator | Returns an enumerator that can iterate through the NameObjectCollectionBase. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetObjectData | Implements the ISerializable interface and returns the data needed to serialize the NameObjectCollectionBase instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
OnDeserialization | Implements the ISerializable interface and raises the deserialization event when the deserialization is complete. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
ctor #1 | Overloaded:.ctor() Default constructor. This constructor is called by derived class constructors to initialize state in this type.Initializes a new instance of the NameObjectCollectionBase class that is empty. |
ctor #2 | Overloaded:.ctor(int capacity) Initializes a new instance of the NameObjectCollectionBase class that is empty and has the specified initial capacity. |
ctor #3 | Overloaded:.ctor(IHashCodeProvider hashProvider, IComparer comparer) Initializes a new instance of the NameObjectCollectionBase class that is empty and uses the specified hash code provider and the specified comparer. |
ctor #4 | Overloaded:.ctor(SerializationInfo info, StreamingContext context) Initializes a new instance of the NameObjectCollectionBase class that is serializable and uses the specified SerializationInfo and StreamingContext. |
ctor #5 | Overloaded:.ctor(int capacity, IHashCodeProvider hashProvider, IComparer comparer) Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity and uses the specified case-insensitive hash code provider and the specified case-insensitive comparer. |
IsReadOnly | Read-write Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only. |
BaseAdd | Adds an entry with the specified key and value into the NameObjectCollectionBase instance. |
BaseClear | Removes all entries from the NameObjectCollectionBase instance. |
BaseGet | Overloaded:BaseGet(int index) Gets the value of the entry at the specified index of the NameObjectCollectionBase instance. |
BaseGet | Overloaded:BaseGet(string name) Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance. |
BaseGetAllKeys | Returns a String array that contains all the keys in the NameObjectCollectionBase instance. |
BaseGetAllValues | Overloaded:BaseGetAllValues() Returns an Object array that contains all the values in the NameObjectCollectionBase instance. |
BaseGetAllValues | Overloaded:BaseGetAllValues(Type type) Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance. |
BaseGetKey | Gets the key of the entry at the specified index of the NameObjectCollectionBase instance. |
BaseHasKeys | Gets a value indicating whether the NameObjectCollectionBase instance contains entries whose keys are not null. |
BaseRemove | Removes the entries with the specified key from the NameObjectCollectionBase instance. |
BaseRemoveAt | Removes the entry at the specified index of the NameObjectCollectionBase instance. |
BaseSet | Overloaded:BaseSet(int index, object value) Sets the value of the entry at the specified index of the NameObjectCollectionBase instance. |
BaseSet | Overloaded:BaseSet(string name, object value) Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
ICollection.CopyTo | Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. |
Hierarchy:
protected NameObjectCollectionBase(); |
The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. The default hash code provider is the CaseInsensitiveHashCodeProvider.
The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.
protected NameObjectCollectionBase( |
capacity
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | capacity is less than zero. |
The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. The default hash code provider is the CaseInsensitiveHashCodeProvider.
The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.
protected NameObjectCollectionBase( |
hashProvider
comparer
The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. The default hash code provider is the CaseInsensitiveHashCodeProvider.
The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.
protected NameObjectCollectionBase( |
info
context
protected NameObjectCollectionBase( |
capacity
hashProvider
comparer
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | capacity is less than zero. |
The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. The default hash code provider is the CaseInsensitiveHashCodeProvider.
The comparer determines whether two keys are equal. The default comparer is the CaseInsensitiveComparer.
public virtual int Count {get;}
|
protected bool IsReadOnly {get; set;}
|
public virtual NameObjectCollectionBase.KeysCollection Keys {get;}
|
name
value
Exception Type | Condition |
---|---|
NotSupportedException | The collection is read-only. |
protected void BaseClear(); |
Exception Type | Condition |
---|---|
NotSupportedException | The collection is read-only. |
index
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | index is outside the valid range of indexes for the collection. |
name
protected string[] BaseGetAllKeys(); |
protected object[] BaseGetAllValues(); |
type
Exception Type | Condition |
---|---|
ArgumentNullException | type is null. |
ArgumentException | type is not a valid Type. |
index
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | index is outside the valid range of indexes for the collection. |
protected bool BaseHasKeys(); |
protected void BaseRemove( |
name
Exception Type | Condition |
---|---|
NotSupportedException | The collection is read-only. -or- The collection has a fixed size. |
protected void BaseRemoveAt( |
index
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | index is outside the valid range of indexes for the collection. |
NotSupportedException | The collection is read-only. -or- The collection has a fixed size. |
index
value
Exception Type | Condition |
---|---|
NotSupportedException | The collection is read-only. |
ArgumentOutOfRangeException | index is outside the valid range of indexes for the collection. |
name
value
Exception Type | Condition |
---|---|
NotSupportedException | The collection is read-only. |
~NameObjectCollectionBase(); |
public IEnumerator GetEnumerator(); |
Enumerators only allow reading the data in the collection. Enumerators cannot be used to modify the underlying collection.
Initially, the enumerator is positioned before the first element in the collection. IEnumerator.Reset also brings the enumerator back to this position. At this position, calling IEnumerator.Current throws an exception. Therefore, you must call IEnumerator.MoveNext to advance the enumerator to the first element of the collection before reading the value of IEnumerator.Current.
IEnumerator.Current returns the same object until either IEnumerator.MoveNext or IEnumerator.Reset is called. IEnumerator.MoveNext sets IEnumerator.Current to the next element.
After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling IEnumerator.MoveNext returns false. If the last call to IEnumerator.MoveNext returned false, calling IEnumerator.Current throws an exception. To set IEnumerator.Current to the first element of the collection again, you can call IEnumerator.Reset followed by IEnumerator.MoveNext.
An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying or deleting elements, the enumerator is irrecoverably invalidated and the next call to IEnumerator.MoveNext or IEnumerator.Reset throws an InvalidOperationException. If the collection is modified between IEnumerator.MoveNext and IEnumerator.Current, IEnumerator.Current will return the element that it is set to, even if the enumerator is already invalidated.
The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
public virtual int GetHashCode(); |
public virtual void GetObjectData( |
info
context
Exception Type | Condition |
---|---|
ArgumentNullException | info is null. |
public Type GetType(); |
protected object MemberwiseClone(); |
public virtual void OnDeserialization( |
sender
Exception Type | Condition |
---|---|
SerializationException | The SerializationInfo object associated with the current NameObjectCollectionBase instance is invalid. |
array
index
Exception Type | Condition |
---|---|
ArgumentNullException | array is null. |
ArgumentOutOfRangeException | index is less than zero. |
ArgumentException | array is multidimensional. -or- index is equal to or greater than the length of array. -or- The number of elements in the source NameObjectCollectionBase is greater than the available space from index to the end of the destination array. |
InvalidCastException | The type of the source NameObjectCollectionBase cannot be cast automatically to the type of the destination array. |
This method uses Array.Copy to copy the elements.
public virtual string ToString(); |