Photon Fusion 2.0.0

Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
SerializableDictionary< TKey, TValue > Class Template Reference

A serializable dictionary. More...

Inherits SerializableDictionary, IDictionary< TKey, TValue >, and ISerializationCallbackReceiver.

Public Member Functions

void Add (TKey key, TValue value)
 Adds the specified key and value to the SerializableDictionary.
 
virtual void Clear ()
 Removes all keys and values from the SerializableDictionary.
 
bool ContainsKey (TKey key)
 Determines whether the SerializableDictionary contains the specified key.
 
Dictionary< TKey, TValue >.Enumerator GetEnumerator ()
 Returns an enumerator that iterates through the SerializableDictionary.
 
bool Remove (TKey key)
 Removes the value with the specified key from the SerializableDictionary.
 
void Reset ()
 Resets the SerializableDictionary, clearing its internal dictionary.
 
void Store ()
 Stores the SerializableDictionary's data into an array for serialization. This includes handling duplicates and null keys.
 
bool TryGetValue (TKey key, out TValue value)
 Gets the value associated with the specified key.
 

Static Public Member Functions

static SerializableDictionary< TKey, TValue > Create< TKey, TValue > ()
 Creates a new serializable dictionary.
 
static SerializableDictionary< TKey, TValue > Wrap (Dictionary< TKey, TValue > dictionary)
 Wraps an existing Dictionary into a SerializableDictionary.
 

Static Public Attributes

const string EntryKeyPropertyPath = nameof(Entry.Key)
 The property path for the key in the Entry structure.
 
const string ItemsPropertyPath = nameof(_items)
 The property path for the items in the SerializableDictionary.
 

Properties

int Count [get]
 Gets the number of key/value pairs contained in the SerializableDictionary.
 
bool IsReadOnly [get]
 Gets a value indicating whether the SerializableDictionary is read-only. This value is always false.
 
Dictionary< TKey, TValue >.KeyCollection Keys [get]
 Gets a collection containing the keys in the SerializableDictionary.
 
TValue this[TKey key] [get, set]
 Gets or sets the value associated with the specified key.
 
Dictionary< TKey, TValue >.ValueCollection Values [get]
 Gets a collection containing the values in the SerializableDictionary.
 

Detailed Description

A serializable dictionary.

Template Parameters
TKeyThe type of the dictionary key.
TValueThe type of the dictionary value.

This class is not thread-safe.

Member Function Documentation

◆ Add()

void Add ( TKey  key,
TValue  value 
)

Adds the specified key and value to the SerializableDictionary.

Parameters
keyThe key of the element to add.
valueThe value of the element to add.

◆ ContainsKey()

bool ContainsKey ( TKey  key)

Determines whether the SerializableDictionary contains the specified key.

Parameters
keyThe key to locate in the SerializableDictionary.
Returns
true if the SerializableDictionary contains an element with the specified key; otherwise, false.

◆ Create< TKey, TValue >()

static SerializableDictionary< TKey, TValue > Create< TKey, TValue > ( )
static

Creates a new serializable dictionary.

Template Parameters
TKeyThe type of the dictionary key.
TValueThe type of the dictionary value.
Returns
A new serializable dictionary.

◆ GetEnumerator()

Dictionary< TKey, TValue >.Enumerator GetEnumerator ( )

Returns an enumerator that iterates through the SerializableDictionary.

Returns
A Dictionary{TKey,TValue}.Enumerator structure for the SerializableDictionary.

◆ Remove()

bool Remove ( TKey  key)

Removes the value with the specified key from the SerializableDictionary.

Parameters
keyThe key of the element to remove.
Returns
true if the element is successfully found and removed; otherwise, false. This method returns false if key is not found in the SerializableDictionary.

◆ TryGetValue()

bool TryGetValue ( TKey  key,
out TValue  value 
)

Gets the value associated with the specified key.

Parameters
keyThe key of the value to get.
valueWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Returns
true if the SerializableDictionary contains an element with the specified key; otherwise, false.

◆ Wrap()

static SerializableDictionary< TKey, TValue > Wrap ( Dictionary< TKey, TValue >  dictionary)
static

Wraps an existing Dictionary into a SerializableDictionary.

Parameters
dictionaryThe Dictionary to be wrapped.
Returns
A new SerializableDictionary that wraps the provided Dictionary.

Property Documentation

◆ this[TKey key]

TValue this[TKey key]
getset

Gets or sets the value associated with the specified key.

Parameters
keyThe key of the value to get or set.
Returns
The value associated with the specified key. If the specified key is not found, a get operation throws a KeyNotFoundException, and a set operation creates a new element with the specified key.