SafeDictionaryTKey, TValue Class |
Namespace: CMS.Base
[SerializableAttribute] public class SafeDictionary<TKey, TValue> : Hashtable, ICloneThreadItem, IXmlSerializable, IGeneralIndexable<TKey, TValue>, IGeneralIndexable
The SafeDictionaryTKey, TValue type exposes the following members.
Name | Description | |
---|---|---|
SafeDictionaryTKey, TValue |
SafeDictionary constructor.
| |
SafeDictionaryTKey, TValue(IEqualityComparer) |
SafeDictionary constructor.
| |
SafeDictionaryTKey, TValue(IDictionary, IEqualityComparer) |
Constructor.
| |
SafeDictionaryTKey, TValue(SerializationInfo, StreamingContext) |
De-serialization constructor.
|
Name | Description | |
---|---|---|
mDefaultValue |
Default value.
| |
mNullValue |
Null value.
| |
mUseWeakReferences |
If true, the weak references are used for the items so the memory can be cleared upon request
|
Name | Description | |
---|---|---|
AllowNulls |
If true, the dictionary allows null values as valid.
| |
CopyToNewThread |
If true, the dictionary is copied (not cloned) to a new thread
| |
DefaultValue |
Default value.
| |
IsSynchronized |
Returns true if dictionary is synchronized.
(Overrides HashtableIsSynchronized.) | |
ItemObject |
Items indexer. Gets or sets the value in the dictionary.
(Overrides HashtableItemObject.) | |
ItemTKey |
Items indexer. Gets or sets the value in the dictionary.
| |
Keys |
Gets an Collection containing the keys in the System.Collections.Hashtable.
(Overrides HashtableKeys.) | |
NullValue |
Null value.
| |
SyncRoot |
Gets an object that can be used to synchronize access to the SafeDictionaryTKey, TValue.
(Overrides HashtableSyncRoot.) | |
TypedKeys |
Gets a typed collection of keys in this dictionary
| |
TypedValues |
Gets a typed collection of values in this dictionary
| |
UseWeakReferences |
If true, the weak references are used for the items so the memory can be cleared upon request.
The property can be set only when the dictionary is empty. To ensure thread-safety, you have
to perform the check for emptiness and property assignment in a critical section (use SyncRoot for that purpose).
| |
Values |
Gets a Collection containing the values in the System.Collections.Hashtable.
(Overrides HashtableValues.) |
Name | Description | |
---|---|---|
Add |
Adds the value to the dictionary if it does not exist.
Updates existing, if it does exist.
(Overrides HashtableAdd(Object, Object).) | |
AddMultiple |
Adds multiple items with same value to the dictionary
| |
Clear |
Removes all elements from the System.Collections.Hashtable.
(Overrides HashtableClear.) | |
Clone |
Clones the dictionary
(Overrides HashtableClone.) | |
CloneForNewThread |
Clones the object for new thread
| |
Contains |
Returns true if the dictionary contains the given key
(Overrides HashtableContains(Object).) | |
ContainsKey |
Returns true if the dictionary contains the given key
(Overrides HashtableContainsKey(Object).) | |
ContainsValue |
Returns true if the dictionary contains the given value
(Overrides HashtableContainsValue(Object).) | |
CopyPropertiesTo |
Copies the dictionary properties to the target dictionary
| |
CopyTo |
Copies the System.Collections.Hashtable elements to a one-dimensional System.Array instance at the specified index.
(Overrides HashtableCopyTo(Array, Int32).) | |
GetInternalValue |
Gets the value from the internal dictionary
| |
GetObjectData |
Object serialization.
(Overrides HashtableGetObjectData(SerializationInfo, StreamingContext).) | |
GetRealCount |
Gets the real count of the objects in the dictionary.
| |
Remove |
Removes the element with the specified key from the System.Collections.Hashtable.
(Overrides HashtableRemove(Object).) | |
SetInternalValue |
Sets the value in the internal dictionary
| |
TryGetValue |
Tries to get the value, returns true if the retrieval was successful.
|
Name | Description | |
---|---|---|
AsIndexableTKey, TValue |
Implicit conversion to indexable type with a specific values
(Defined by DataExtensions.) |
Keep in mind that the operations of this class are thread-safe. However, a sequence of operations inherently cannot be thread-safe. If you want to perform multiple operations as one atomic operation, use the SyncRoot object.
In current implementation some read operations do not require locking (i.e. multiple threads can read even though some other thread has the lock). If your situation requires all the readers to wait when the dictionary is locked by some other thread, consider some other collection suitable for readers-writers synchronization problem.