Rebornbuddy
Loading...
Searching...
No Matches
ff14bot.Helpers.LocalizedDictionary< K, V > Class Template Reference

LocalizedDictionary provides a dictionary that provides 3 different keys, a user-supplied type(often an int), and two strings. More...

Public Member Functions

bool TryGetValue (K primaryKey, out V val)
 Gets the value associated with the specified key.
bool ContainsKey (K primaryKey)
 Determines whether the T:System.Collections.Generic.Dictionary`2 contains the specified key.
void Add (K primaryKey, string englishKey, string localizedKey, V val)
 Adds the item to the dictionaries. If englishkey or Localizedkey are null or empty then the item is only the primarykey will be used.
V[] CloneValues ()
IEnumerator< KeyValuePair< K, V > > GetEnumerator ()
 Gets a collection containing the values in the T:System.Collections.Generic.Dictionary`2.

Properties

this[string subKey] [get]
 Gets or sets the value associated with the specified key.
this[K primaryKey] [get]
 Gets or sets the value associated with the specified key.

Detailed Description

LocalizedDictionary provides a dictionary that provides 3 different keys, a user-supplied type(often an int), and two strings.


Template Parameters
KPrimary Key Type
VValue Type

Member Function Documentation

◆ Add()

void ff14bot.Helpers.LocalizedDictionary< K, V >.Add ( K primaryKey,
string englishKey,
string localizedKey,
V val )

Adds the item to the dictionaries. If englishkey or Localizedkey are null or empty then the item is only the primarykey will be used.

Parameters
primaryKey
englishKey
localizedKey
val

◆ CloneValues()

V[] ff14bot.Helpers.LocalizedDictionary< K, V >.CloneValues ( )
Returns

◆ ContainsKey()

bool ff14bot.Helpers.LocalizedDictionary< K, V >.ContainsKey ( K primaryKey)

Determines whether the T:System.Collections.Generic.Dictionary`2 contains the specified key.

/

Parameters
subKeyThe key to locate in the T:System.Collections.Generic.Dictionary`2.
Returns
true if the T:System.Collections.Generic.Dictionary`2 contains an element with the specified key; otherwise, false.

/

Exceptions
T:System.ArgumentNullException/ subKey is null.

public bool ContainsKey(string subKey) { return TryGetValue(subKey, out var val); }

/ Determines whether the T:System.Collections.Generic.Dictionary`2 contains the specified key.

Parameters
primaryKeyThe key to locate in the T:System.Collections.Generic.Dictionary`2.

/

Returns
/ true if the T:System.Collections.Generic.Dictionary`2 contains an element with the specified key; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionprimaryKey is null.

◆ GetEnumerator()

IEnumerator< KeyValuePair< K, V > > ff14bot.Helpers.LocalizedDictionary< K, V >.GetEnumerator ( )

Gets a collection containing the values in the T:System.Collections.Generic.Dictionary`2.

/

Returns
A T:System.Collections.Generic.Dictionary`2.ValueCollection containing the values in the T:System.Collections.Generic.Dictionary`2.

public List<V> Values { get { _readerWriterLock.EnterReadLock();

try { return BaseDictionary.Values.ToList(); } finally { _readerWriterLock.ExitReadLock(); } } } /

/ / /

Returns

public K[] ClonePrimaryKeys() { _readerWriterLock.EnterReadLock();

try { K[] values = new K[BaseDictionary.Keys.Count];

BaseDictionary.Keys.CopyTo(values, 0);

return values; } finally { _readerWriterLock.ExitReadLock(); } }

/

/ Clear the dictionaries / public void Clear() { _readerWriterLock.EnterWriteLock();

try { BaseDictionary.Clear(); SubEnglishDictionary.Clear(); SubLocalizedDictionary.Clear(); } finally { _readerWriterLock.ExitWriteLock(); } }

/

/ Number of entries in the primary dictionary / public int Count { get { _readerWriterLock.EnterReadLock();

try { return BaseDictionary.Count; } finally { _readerWriterLock.ExitReadLock(); } } }

/ Returns an enumerator that iterates through the T:System.Collections.Generic.Dictionary`2.

Returns
A T:System.Collections.Generic.Dictionary`2.Enumerator structure for the T:System.Collections.Generic.Dictionary`2.

◆ TryGetValue()

bool ff14bot.Helpers.LocalizedDictionary< K, V >.TryGetValue ( K primaryKey,
out V val )

Gets the value associated with the specified key.

Parameters
subKeyThe key of the value to get.
valWhen 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 T:System.Collections.Generic.Dictionary`2 contains an element with the specified key; otherwise, false.

/

Exceptions
T:System.ArgumentNullException/ subKey is null.

public bool TryGetValue(string subKey, out V val) { val = default(V);

_readerWriterLock.EnterReadLock();

try { K primaryKey; if (SubEnglishDictionary.TryGetValue(subKey, out val)) { return true; } if (DataManager.CurrentLanguage != Language.Eng) { if (SubLocalizedDictionary.TryGetValue(subKey, out val)) { return true; } }

        }
        finally
        {
            _readerWriterLock.ExitReadLock();
        }

        return false;
    }

/ Gets the value associated with the specified key. /

Parameters
primaryKeyThe key of the value to get.

/

Parameters
valWhen 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 T:System.Collections.Generic.Dictionary`2 contains an element with the specified key; otherwise, false.
Exceptions
T:System.ArgumentNullExceptionprimaryKey is null.

Property Documentation

◆ this[K primaryKey]

V ff14bot.Helpers.LocalizedDictionary< K, V >.this[K primaryKey]
get

Gets or sets the value associated with the specified key.

Parameters
primaryKeyThe 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 T:System.Collections.Generic.KeyNotFoundException, and a set operation creates a new element with the specified key.
Exceptions
T:System.ArgumentNullExceptionprimaryKey is null.
T:System.Collections.Generic.KeyNotFoundExceptionThe property is retrieved and primaryKey does not exist in the collection.

◆ this[string subKey]

V ff14bot.Helpers.LocalizedDictionary< K, V >.this[string subKey]
get

Gets or sets the value associated with the specified key.

Parameters
subKeyThe 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 T:System.Collections.Generic.KeyNotFoundException, and a set operation creates a new element with the specified key.
Exceptions
T:System.ArgumentNullExceptionsubKey is null.
T:System.Collections.Generic.KeyNotFoundExceptionThe property is retrieved and subKey does not exist in the collection.