예제 #1
0
        //加载文件内容
        private void LoadFile()
        {
            string sz = dpz3.File.UTF8File.ReadAllText(path, false);

            string[]          lines = sz.Replace("\r", "").Split('\n');
            Conf.SettingGroup group = null;

            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i].Trim();
                if (line.IsNoneOrNull())
                {
                    if (group == null)
                    {
                        group = new Conf.SettingGroup()
                        {
                            Name = ""
                        };
                        this.Groups.Add(group);
                    }
                }
                else if (line.StartsWith("[") && line.EndsWith("]"))
                {
                    group = new Conf.SettingGroup()
                    {
                        Name = line.Substring(1, line.Length - 2)
                    };
                    this.Groups.Add(group);
                }
                else
                {
                    if (group == null)
                    {
                        group = new Conf.SettingGroup()
                        {
                            Name = ""
                        };
                        this.Groups.Add(group);
                    }
                    if (line.StartsWith("#"))
                    {
                        group.AddNote(line.Substring(1));
                    }
                    else
                    {
                        int idx = line.IndexOf("=");
                        if (idx < 0)
                        {
                            group.Set(line);
                        }
                        else
                        {
                            group.Set(line.Substring(0, idx).Trim(), line.Substring(idx + 1).Trim());
                        }
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// 获取一个设置组
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public Conf.SettingGroup this[string name] {
     get {
         for (int i = 0; i < this.Groups.Count; i++)
         {
             Conf.SettingGroup group = this.Groups[i];
             if (group.Name == name)
             {
                 return(group);
             }
         }
         Conf.SettingGroup newGroup = new Conf.SettingGroup()
         {
             Name = name
         };
         this.Groups.Add(newGroup);
         return(newGroup);
     }
 }
예제 #3
0
 public ApiInfo(dpz3.File.Conf.SettingGroup group)
 {
     this.Url = group["url"];
     this.Id  = group["id"];
     this.Key = group["key"];
 }