Class IntegerKeyDictionaryConverter
Converts dictionaries with string keys to dictionaries with integer keys for more efficient storage and lookup.
public class IntegerKeyDictionaryConverter : IMakeXmlSource
- Inheritance
-
IntegerKeyDictionaryConverter
- Implements
- Inherited Members
- Extension Methods
Constructors
IntegerKeyDictionaryConverter()
Initializes a new instance of the IntegerKeyDictionaryConverter class.
public IntegerKeyDictionaryConverter()
IntegerKeyDictionaryConverter(XElement)
Initializes a new instance of the IntegerKeyDictionaryConverter class from XML.
public IntegerKeyDictionaryConverter(XElement src)
Parameters
src
XElementXML element containing the converter data.
Properties
RawKeyList
Dont modify.
public List<string> RawKeyList { get; }
Property Value
RawKeyToIndex
Dont modify.
public Dictionary<string, int> RawKeyToIndex { get; }
Property Value
XName
Name for XML IO.
public static string XName { get; }
Property Value
Methods
GetIntegerKeyDictionary(Dictionary<string, object>)
Converts a dictionary with string keys to a dictionary with integer keys.
public Dictionary<int, object> GetIntegerKeyDictionary(Dictionary<string, object> rawKeyDictionary)
Parameters
rawKeyDictionary
Dictionary<string, object>The dictionary with string keys to convert.
Returns
- Dictionary<int, object>
A dictionary with integer keys.
GetRestoredDictionary(Dictionary<int, object>)
Converts a dictionary with integer keys back to a dictionary with string keys.
public Dictionary<string, object> GetRestoredDictionary(Dictionary<int, object> integerKeyDictionary)
Parameters
integerKeyDictionary
Dictionary<int, object>The dictionary with integer keys to convert.
Returns
- Dictionary<string, object>
A dictionary with string keys.
MakeXmlSource(string, string, bool)
Creates an XML representation of the object. This method may also generate additional resources such as related files.
public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibitionOnly)
Parameters
baseDirectory
stringThe base directory for resolving relative paths
relFile
stringThe relative file path for the XML source
exhibitionOnly
boolif true, the extended file creation is suppressed.
Returns
- XElement
An XML element representing the object's state
Remarks
For the demand of easy moving source folder (especially project folder) without configuration file path corruption, the relative file path is applied.
The baseDirectory
is typically the folder at the nearest configuration file folder.
Since the folder can be moving with the configuration file.