Ejemplo n.º 1
0
        /// <include file='IniDocument.xml' path='//Method[@name="SaveTextWriter"]/docs/*' />
        public void Save(TextWriter textWriter)
        {
            var        writer  = GetIniWriter(textWriter, FileType);
            IniItem    item    = null;
            IniSection section = null;

            foreach (string comment in initialComment)
            {
                writer.WriteEmpty(comment);
            }

            for (int j = 0; j < Sections.Count; j++)
            {
                section = Sections[j];
                writer.WriteSection(section.Name, section.Comment);
                for (int i = 0; i < section.ItemCount; i++)
                {
                    item = section.GetItem(i);
                    switch (item.Type)
                    {
                    case IniType.Key:
                        writer.WriteKey(item.Name, item.Value, item.Comment);
                        break;

                    case IniType.Empty:
                        writer.WriteEmpty(item.Comment);
                        break;
                    }
                }
            }

            writer.Close();
        }
Ejemplo n.º 2
0
        /// <include file='IniSection.xml' path='//Method[@name="SetComment"]/docs/*' />
        public void Set(string comment)
        {
            string name = "#comment" + commentCount;
            var    item = new IniItem(name, null,
                                      IniType.Empty, comment);

            configList.Add(name, item);

            commentCount++;
        }
Ejemplo n.º 3
0
        /// <include file='IniSection.xml' path='//Method[@name="SetKeyComment"]/docs/*' />
        public void Set(string key, string value, string comment)
        {
            IniItem item = null;

            if (Contains(key))
            {
                item         = (IniItem)configList[key];
                item.Value   = value;
                item.Comment = comment;
            }
            else
            {
                item = new IniItem(key, value, IniType.Key, comment);
                configList.Add(key, item);
            }
        }
Ejemplo n.º 4
0
        /// <include file='IniSection.xml' path='//Method[@name="GetKeys"]/docs/*' />
        public string[] GetKeys()
        {
            var     list = new ArrayList();
            IniItem item = null;

            for (int i = 0; i < configList.Count; i++)
            {
                item = (IniItem)configList[i];
                if (item.Type == IniType.Key)
                {
                    list.Add(item.Name);
                }
            }
            var result = new string[list.Count];

            list.CopyTo(result, 0);

            return(result);
        }