Hydrogen Framework  1.3.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Hydrogen.Serialization.INI Class Reference

Static Public Member Functions

static List< KeyValuePair
< string, string > > 
Deserialize (string iniString, char seperatorCharacter= '=')
 Deserialize the specified iniString and seperatorCharacter. More...
 
static string Serialize (Dictionary< string, string > data, char seperatorCharacter= '=')
 Serialize the specified data and seperatorCharacter. More...
 
static string Serialize (List< KeyValuePair< string, string >> data, char seperatorCharacter= '=')
 Serialize the specified data and seperatorCharacter. More...
 

Detailed Description

Definition at line 36 of file INI.cs.

Member Function Documentation

static List<KeyValuePair<string, string> > Hydrogen.Serialization.INI.Deserialize ( string  iniString,
char  seperatorCharacter = '=' 
)
static

Deserialize the specified iniString and seperatorCharacter.

Parameters
iniStringIni string.
seperatorCharacterSeperator character.

Definition at line 43 of file INI.cs.

44  {
45  var entries = new List<KeyValuePair<string, string>> ();
46 
47  using (var reader = new StringReader (iniString)) {
48  string line;
49  while ((line = reader.ReadLine ()) != null) {
50  line = line.Trim ();
51  if (line.Length == 0)
52  continue;
53 
54  if (!line.Contains (seperatorCharacter.ToString ()))
55  continue;
56 
57  int first = line.IndexOf (seperatorCharacter);
58 
59  entries.Add (new KeyValuePair<string, string> (
60  line.Substring (0, first).Trim (), line.Substring (first + 1).Trim ()));
61  }
62  }
63  return entries;
64  }
static string Hydrogen.Serialization.INI.Serialize ( Dictionary< string, string >  data,
char  seperatorCharacter = '=' 
)
static

Serialize the specified data and seperatorCharacter.

Parameters
dataData.
seperatorCharacterSeperator character.

Definition at line 71 of file INI.cs.

72  {
73  var iniString = new StringBuilder ();
74 
75  foreach (string s in data.Keys) {
76  iniString.AppendLine (s.Trim () + seperatorCharacter + data [s].Trim ());
77  }
78 
79  return iniString.ToString ();
80  }
static string Hydrogen.Serialization.INI.Serialize ( List< KeyValuePair< string, string >>  data,
char  seperatorCharacter = '=' 
)
static

Serialize the specified data and seperatorCharacter.

Parameters
dataData.
seperatorCharacterSeperator character.

Definition at line 87 of file INI.cs.

88  {
89  var iniString = new StringBuilder ();
90 
91  for (int x = 0; x < data.Count; x++) {
92  iniString.AppendLine (data [x].Key.Trim () + seperatorCharacter + data [x].Value.Trim ());
93  }
94 
95  return iniString.ToString ();
96  }