示例#1
0
 public InfoCollection this[string key]
 {
     get
     {
         if (!DB.ContainsKey(key))
             DB[key] = new InfoCollection();
         return DB[key];
     }
     set
     {
         DB[key] = value;
     }
 }
示例#2
0
 public InfoCollection this[string key]
 {
     get
     {
         if (!DB.ContainsKey(key))
         {
             DB[key] = new InfoCollection();
         }
         return(DB[key]);
     }
     set
     {
         DB[key] = value;
     }
 }
示例#3
0
        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));
            }
        }
示例#4
0
        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);
            }
        }