12 internal class NameObjectEntry
16 internal object Value;
18 internal NameObjectEntry(
string name,
object value)
26 internal class NameObjectKeysEnumerator :
IEnumerator 38 if (_pos >= 0 && _pos < _coll.
Count)
49 _version = _coll._version;
53 public bool MoveNext()
55 if (_version != _coll._version)
59 if (_pos < _coll.
Count - 1)
70 if (_version != _coll._version)
89 public string this[
int index]
132 public virtual string Get(
int index)
141 return new NameObjectKeysEnumerator(_coll);
168 if (array.Length - index < _coll.
Count)
173 while (enumerator.MoveNext())
175 array.SetValue(enumerator.Current, index++);
180 private const string ReadOnlyName =
"ReadOnly";
182 private const string CountName =
"Count";
184 private const string ComparerName =
"Comparer";
186 private const string HashCodeProviderName =
"HashProvider";
188 private const string KeysName =
"Keys";
190 private const string ValuesName =
"Values";
192 private const string KeyComparerName =
"KeyComparer";
194 private const string VersionName =
"Version";
196 private bool _readOnly;
198 private ArrayList _entriesArray;
200 private IEqualityComparer _keyComparer;
202 private volatile Hashtable _entriesTable;
204 private volatile NameObjectEntry _nullKeyEntry;
206 private KeysCollection _keys;
210 private int _version;
213 private object _syncRoot;
215 private static StringComparer defaultComparer = StringComparer.InvariantCultureIgnoreCase;
217 internal IEqualityComparer Comparer
225 _keyComparer = value;
246 public virtual int Count => _entriesArray.Count;
254 if (_syncRoot ==
null)
275 public virtual KeysCollection
Keys 289 : this(defaultComparer)
298 if (equalityComparer !=
null)
300 keyComparer = equalityComparer;
305 keyComparer = equalityComparer2;
317 : this(equalityComparer)
325 [Obsolete(
"Please use NameObjectCollectionBase(IEqualityComparer) instead.")]
328 _keyComparer =
new CompatibleComparer(comparer, hashProvider);
338 [Obsolete(
"Please use NameObjectCollectionBase(Int32, IEqualityComparer) instead.")]
341 _keyComparer =
new CompatibleComparer(comparer, hashProvider);
364 _serializationInfo = info;
379 info.AddValue(
"ReadOnly", _readOnly);
380 if (_keyComparer == defaultComparer)
382 info.AddValue(
"HashProvider", CompatibleComparer.DefaultHashCodeProvider, typeof(
IHashCodeProvider));
383 info.AddValue(
"Comparer", CompatibleComparer.DefaultComparer, typeof(
IComparer));
385 else if (_keyComparer ==
null)
388 info.AddValue(
"Comparer",
null, typeof(
IComparer));
390 else if (_keyComparer is CompatibleComparer)
392 CompatibleComparer compatibleComparer = (CompatibleComparer)_keyComparer;
393 info.AddValue(
"HashProvider", compatibleComparer.HashCodeProvider, typeof(
IHashCodeProvider));
394 info.AddValue(
"Comparer", compatibleComparer.Comparer, typeof(
IComparer));
400 int count = _entriesArray.Count;
401 info.AddValue(
"Count", count);
402 string[] array =
new string[count];
403 object[] array2 =
new object[count];
404 for (
int i = 0; i < count; i++)
406 NameObjectEntry nameObjectEntry = (NameObjectEntry)_entriesArray[i];
407 array[i] = nameObjectEntry.Key;
408 array2[i] = nameObjectEntry.Value;
410 info.AddValue(
"Keys", array, typeof(
string[]));
411 info.AddValue(
"Values", array2, typeof(
object[]));
412 info.AddValue(
"Version", _version);
420 if (_keyComparer !=
null)
424 if (_serializationInfo ==
null)
429 _serializationInfo =
null;
430 bool readOnly =
false;
432 string[] array =
null;
433 object[] array2 =
null;
441 switch (enumerator.
Name)
444 readOnly = serializationInfo.
GetBoolean(
"ReadOnly");
456 num = serializationInfo.
GetInt32(
"Count");
459 array = (
string[])serializationInfo.
GetValue(
"Keys", typeof(
string[]));
462 array2 = (
object[])serializationInfo.
GetValue(
"Values", typeof(
object[]));
466 version = serializationInfo.
GetInt32(
"Version");
470 if (_keyComparer ==
null)
472 if (comparer ==
null || hashCodeProvider ==
null)
476 _keyComparer =
new CompatibleComparer(comparer, hashCodeProvider);
478 if (array ==
null || array2 ==
null)
483 for (
int i = 0; i < num; i++)
487 _readOnly = readOnly;
497 _entriesTable =
new Hashtable(_keyComparer);
498 _nullKeyEntry =
null;
502 private void Reset(
int capacity)
505 _entriesTable =
new Hashtable(capacity, _keyComparer);
506 _nullKeyEntry =
null;
510 private NameObjectEntry FindEntry(
string key)
514 return (NameObjectEntry)_entriesTable[key];
516 return _nullKeyEntry;
524 return _entriesTable.Count > 0;
531 protected void BaseAdd(
string name,
object value)
537 NameObjectEntry nameObjectEntry =
new NameObjectEntry(name, value);
540 if (_entriesTable[name] ==
null)
542 _entriesTable.Add(name, nameObjectEntry);
545 else if (_nullKeyEntry ==
null)
547 _nullKeyEntry = nameObjectEntry;
549 _entriesArray.Add(nameObjectEntry);
564 _entriesTable.Remove(name);
565 for (
int num = _entriesArray.Count - 1; num >= 0; num--)
567 if (_keyComparer.Equals(name,
BaseGetKey(num)))
569 _entriesArray.RemoveAt(num);
575 _nullKeyEntry =
null;
576 for (
int num2 = _entriesArray.Count - 1; num2 >= 0; num2--)
580 _entriesArray.RemoveAt(num2);
601 _entriesTable.Remove(text);
605 _nullKeyEntry =
null;
607 _entriesArray.RemoveAt(index);
627 return FindEntry(name)?.Value;
634 protected void BaseSet(
string name,
object value)
640 NameObjectEntry nameObjectEntry = FindEntry(name);
641 if (nameObjectEntry !=
null)
643 nameObjectEntry.Value = value;
659 NameObjectEntry nameObjectEntry = (NameObjectEntry)_entriesArray[index];
660 return nameObjectEntry.Value;
670 NameObjectEntry nameObjectEntry = (NameObjectEntry)_entriesArray[index];
671 return nameObjectEntry.Key;
680 protected void BaseSet(
int index,
object value)
686 NameObjectEntry nameObjectEntry = (NameObjectEntry)_entriesArray[index];
687 nameObjectEntry.Value = value;
695 return new NameObjectKeysEnumerator(
this);
722 if (array.Length - index < _entriesArray.Count)
724 throw new ArgumentException(SR.GetString(
"Arg_InsufficientSpace"));
727 while (enumerator.MoveNext())
729 array.SetValue(enumerator.Current, index++);
737 int count = _entriesArray.Count;
738 string[] array =
new string[count];
739 for (
int i = 0; i < count; i++)
750 int count = _entriesArray.Count;
751 object[] array =
new object[count];
752 for (
int i = 0; i < count; i++)
768 int count = _entriesArray.Count;
773 object[] array = (
object[])SecurityUtils.ArrayCreateInstance(type, count);
774 for (
int i = 0; i < count; i++)
Supplies a hash code for an object, using a custom hash function.
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
NameObjectCollectionBase(SerializationInfo info, StreamingContext context)
Initializes a new instance of the T:System.Collections.Specialized.NameObjectCollectionBase class tha...
void BaseRemoveAt(int index)
Removes the entry at the specified index of the T:System.Collections.Specialized.NameObjectCollection...
object [] BaseGetAllValues()
Returns an T:System.Object array that contains all the values in the T:System.Collections....
The content of the collection was cleared.
Indicates that a class is to be notified when deserialization of the entire object graph has been com...
bool GetBoolean(string name)
Retrieves a Boolean value from the T:System.Runtime.Serialization.SerializationInfo store.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
SerializationInfoEnumerator GetEnumerator()
Returns a T:System.Runtime.Serialization.SerializationInfoEnumerator used to iterate through the name...
IEnumerator GetEnumerator()
Returns an enumerator that iterates through the T:System.Collections.Specialized.NameObjectCollection...
NameObjectCollectionBase(IHashCodeProvider hashProvider, IComparer comparer)
Initializes a new instance of the T:System.Collections.Specialized.NameObjectCollectionBase class tha...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
NameObjectCollectionBase(int capacity, IEqualityComparer equalityComparer)
Initializes a new instance of the T:System.Collections.Specialized.NameObjectCollectionBase class tha...
SecurityAction
Specifies the security actions that can be performed using declarative security.
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
void BaseClear()
Removes all entries from the T:System.Collections.Specialized.NameObjectCollectionBase instance.
object [] BaseGetAllValues(Type type)
Returns an array of the specified type that contains all the values in the T:System....
string [] BaseGetAllKeys()
Returns a T:System.String array that contains all the keys in the T:System.Collections....
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
Defines methods to support the comparison of objects for equality.
virtual IEnumerator GetEnumerator()
Returns an enumerator that iterates through the T:System.Collections.Specialized.NameObjectCollection...
Exposes a method that compares two objects.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
Represents type declarations: class types, interface types, array types, value types,...
Represents a collection of the T:System.String keys of a collection.
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Implements the T:System.Runtime.Serialization.ISerializable interface and returns the data needed to ...
NameObjectCollectionBase(int capacity)
Initializes a new instance of the T:System.Collections.Specialized.NameObjectCollectionBase class tha...
The exception thrown when an error occurs during serialization or deserialization.
string BaseGetKey(int index)
Gets the key of the entry at the specified index of the T:System.Collections.Specialized....
virtual KeysCollection Keys
Gets a T:System.Collections.Specialized.NameObjectCollectionBase.KeysCollection instance that contain...
Provides the abstract base class for a collection of associated T:System.String keys and T:System....
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
static StringComparer InvariantCultureIgnoreCase
Gets a T:System.StringComparer object that performs a case-insensitive string comparison using the wo...
NameObjectCollectionBase(int capacity, IHashCodeProvider hashProvider, IComparer comparer)
Initializes a new instance of the T:System.Collections.Specialized.NameObjectCollectionBase class tha...
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
The exception that is thrown when one of the arguments provided to a method is not valid.
object BaseGet(int index)
Gets the value of the entry at the specified index of the T:System.Collections.Specialized....
virtual void OnDeserialization(object sender)
Implements the T:System.Runtime.Serialization.ISerializable interface and raises the deserialization ...
Allows an object to control its own serialization and deserialization.
int Count
Gets the number of keys in the T:System.Collections.Specialized.NameObjectCollectionBase....
object BaseGet(string name)
Gets the value of the first entry with the specified key from the T:System.Collections....
object GetValue(string name, Type type)
Retrieves a value from the T:System.Runtime.Serialization.SerializationInfo store.
Specifies that the class can be serialized.
string Name
Gets the name for the item currently being examined.
virtual int Count
Gets the number of key/value pairs contained in the T:System.Collections.Specialized....
The exception that is thrown when a method call is invalid for the object's current state.
int GetInt32(string name)
Retrieves a 32-bit signed integer value from the T:System.Runtime.Serialization.SerializationInfo sto...
NameObjectCollectionBase()
Initializes a new instance of the T:System.Collections.Specialized.NameObjectCollectionBase class tha...
void BaseSet(string name, object value)
Sets the value of the first entry with the specified key in the T:System.Collections....
virtual string Get(int index)
Gets the key at the specified index of the collection.
Provides information about a specific culture (called a locale for unmanaged code development)....
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.
SecurityPermissionFlag
Specifies access flags for the security permission object.
bool BaseHasKeys()
Gets a value indicating whether the T:System.Collections.Specialized.NameObjectCollectionBase instanc...
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
void BaseRemove(string name)
Removes the entries with the specified key from the T:System.Collections.Specialized....
Provides a formatter-friendly mechanism for parsing the data in T:System.Runtime.Serialization....
void BaseSet(int index, object value)
Sets the value of the entry at the specified index of the T:System.Collections.Specialized....
void BaseAdd(string name, object value)
Adds an entry with the specified key and value into the T:System.Collections.Specialized....
Provides atomic operations for variables that are shared by multiple threads.
Supports a simple iteration over a non-generic collection.
bool IsReadOnly
Gets or sets a value indicating whether the T:System.Collections.Specialized.NameObjectCollectionBase...
Represents a string comparison operation that uses specific case and culture-based or ordinal compari...
Represents a nonexistent value. This class cannot be inherited.
NameObjectCollectionBase(IEqualityComparer equalityComparer)
Initializes a new instance of the T:System.Collections.Specialized.NameObjectCollectionBase class tha...
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
bool MoveNext()
Updates the enumerator to the next item.