public InfoCollection this[string key] { get { if (!DB.ContainsKey(key)) DB[key] = new InfoCollection(); return DB[key]; } set { DB[key] = value; } }
public InfoCollection this[string key] { get { if (!DB.ContainsKey(key)) { DB[key] = new InfoCollection(); } return(DB[key]); } set { DB[key] = value; } }
static public Configuration Read(Stream source) { try { StreamReader reader = new StreamReader(source); Encoding enc = Encoding.Unicode; Configuration result = new Configuration(enc); InfoCollection currentKey = null; string currentKeyName = ""; while (!reader.EndOfStream) { string line = reader.ReadLine().Trim(); if (line.StartsWith("[") && line.EndsWith("]")) { if (line.Length > 2) { currentKey = new InfoCollection(); currentKeyName = line.Substring(1, line.Length - 2); result[currentKeyName] = currentKey; } else { currentKey = null; currentKeyName = ""; } } else if (currentKey != null && line.Contains("=")) { string keyTag = line.Substring(0, line.IndexOf("=")).Trim().ToUpper(); string keyValue = line.Substring(line.IndexOf("=") + 1).Trim(); currentKey[keyTag] = keyValue; } else if (line.Length > 0) { currentKey[line] = ""; } } return(result); } catch { return(new Configuration(Encoding.Unicode)); } }
public static Configuration Read(Stream source) { try { StreamReader reader = new StreamReader(source); Encoding enc = Encoding.Unicode; Configuration result = new Configuration(enc); InfoCollection currentKey = null; string currentKeyName = ""; while (!reader.EndOfStream) { string line = reader.ReadLine().Trim(); if (line.StartsWith("[") && line.EndsWith("]")) { if (line.Length > 2) { currentKey = new InfoCollection(); currentKeyName = line.Substring(1, line.Length - 2); result[currentKeyName] = currentKey; } else { currentKey = null; currentKeyName = ""; } } else if (currentKey != null && line.Contains("=")) { string keyTag = line.Substring(0, line.IndexOf("=")).Trim().ToUpper(); string keyValue = line.Substring(line.IndexOf("=") + 1).Trim(); currentKey[keyTag] = keyValue; } else if (line.Length > 0) { currentKey[line] = ""; } } return result; } catch { return new Configuration(Encoding.Unicode); } }