Exemple #1
0
 public void Read()
 {
     #region IniSectionSelect
     string[] Lines = File.ReadAllLines(path);
     string Ssection = "";
     foreach (string Line in Lines)
     {
         if (Line.Length > 0)
         {
             if (Line[0] == '[' && Line[Line.Length - 1] == ']')
             {
                 Ssection = Line;
                 IniSectionStructure Section = new IniSectionStructure();
                 Section.SectionName = Ssection;
                 Section.Variables = new Dictionary<string, IniValueStructure>();
                 Sections.Add(Ssection, Section);
             }
             else
             {
                 IniValueStructure IvS = new IniValueStructure();
                 IvS.Variable = Line.Split('=')[0];
                 IvS.Value = Line.Split('=')[1];
                 IniSectionStructure Section = null;
                 Sections.TryGetValue(Ssection, out Section);
                 if (Section != null)
                 {
                     if (!Section.Variables.ContainsKey(IvS.Variable))
                         Section.Variables.Add(IvS.Variable, IvS);
                 }
             }
         }
     }
     #endregion
 }
Exemple #2
0
        private void IniWriteValue(string ssection, string Key, string Value)
        {
            string section = "[" + ssection + "]";
            IniSectionStructure _Section = null;

            Sections.TryGetValue(section, out _Section);
            if (_Section != null)
            {
                IniValueStructure IVS = null;
                _Section.Variables.TryGetValue(Key, out IVS);
                if (IVS != null)
                {
                    if (IVS.Variable == Key)
                    {
                        IVS.Value = Value;
                    }
                }
                else
                {
                    _Section.Variables.Add(Key, new IniValueStructure()
                    {
                        Value = Value, Variable = Key
                    });
                }
            }
            else
            {
                _Section = new IniSectionStructure()
                {
                    SectionName = section, Variables = new Dictionary <string, IniValueStructure>()
                };
                Sections.Add(section, _Section);
                IniValueStructure IVS = null;
                _Section.Variables.TryGetValue(Key, out IVS);
                if (IVS != null)
                {
                    if (IVS.Variable == Key)
                    {
                        IVS.Value = Value;
                    }
                }
                else
                {
                    _Section.Variables.Add(Key, new IniValueStructure()
                    {
                        Value = Value, Variable = Key
                    });
                }
            }
        }
Exemple #3
0
        public string ReadString(string Section, string Key)
        {
            string section          = "[" + Section + "]";
            IniSectionStructure ISS = null;

            Sections.TryGetValue(section, out ISS);
            if (ISS != null)
            {
                IniValueStructure IVS = null;
                ISS.Variables.TryGetValue(Key, out IVS);
                if (IVS != null)
                {
                    return(IVS.Value);
                }
            }
            return("");
        }
Exemple #4
0
        public float ReadFloat(string Section, string Key)
        {
            string section          = "[" + Section + "]";
            IniSectionStructure ISS = null;

            Sections.TryGetValue(section, out ISS);
            if (ISS != null)
            {
                IniValueStructure IVS = null;
                ISS.Variables.TryGetValue(Key, out IVS);
                if (IVS != null)
                {
                    return(float.Parse(IVS.Value));
                }
            }
            return(0);
        }
Exemple #5
0
        public bool ReadBoolean(string Section, string Key)
        {
            string section          = "[" + Section + "]";
            IniSectionStructure ISS = null;

            Sections.TryGetValue(section, out ISS);
            if (ISS != null)
            {
                IniValueStructure IVS = null;
                ISS.Variables.TryGetValue(Key, out IVS);
                if (IVS != null)
                {
                    return(byte.Parse(IVS.Value) == 1 ? true : false);
                }
                ;
            }
            return(false);
        }
Exemple #6
0
 public void Read()
 {
     #region IniSectionSelect
     string[] Lines    = File.ReadAllLines(path);
     string   Ssection = "";
     foreach (string Line in Lines)
     {
         if (Line.Length > 0)
         {
             if (Line[0] == '[' && Line[Line.Length - 1] == ']')
             {
                 Ssection = Line;
                 IniSectionStructure Section = new IniSectionStructure();
                 Section.SectionName = Ssection;
                 Section.Variables   = new Dictionary <string, IniValueStructure>();
                 Sections.Add(Ssection, Section);
             }
             else
             {
                 IniValueStructure IvS = new IniValueStructure();
                 IvS.Variable = Line.Split('=')[0];
                 IvS.Value    = Line.Split('=')[1];
                 IniSectionStructure Section = null;
                 Sections.TryGetValue(Ssection, out Section);
                 if (Section != null)
                 {
                     if (!Section.Variables.ContainsKey(IvS.Variable))
                     {
                         Section.Variables.Add(IvS.Variable, IvS);
                     }
                 }
             }
         }
     }
     #endregion
 }
Exemple #7
0
 private void IniWriteValue(string ssection, string Key, string Value)
 {
     string section = "[" + ssection + "]";
     IniSectionStructure _Section = null;
     Sections.TryGetValue(section, out _Section);
     if (_Section != null)
     {
         IniValueStructure IVS = null;
         _Section.Variables.TryGetValue(Key, out IVS);
         if (IVS != null)
         {
             if (IVS.Variable == Key)
             {
                 IVS.Value = Value;
             }
         }
         else
         {
             _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
         }
     }
     else
     {
         _Section = new IniSectionStructure() { SectionName = section, Variables = new Dictionary<string, IniValueStructure>() };
         Sections.Add(section, _Section);
         IniValueStructure IVS = null;
         _Section.Variables.TryGetValue(Key, out IVS);
         if (IVS != null)
         {
             if (IVS.Variable == Key)
             {
                 IVS.Value = Value;
             }
         }
         else
         {
             _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
         }
     }
 }