Exemplo n.º 1
0
        /// <include file='IniDocument.xml' path='//Method[@name="SaveTextWriter"]/docs/*' />
        public void Save(TextWriter textWriter)
        {
            IniWriter  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();
        }
Exemplo n.º 2
0
        /// <include file='IniSection.xml' path='//Method[@name="SetComment"]/docs/*' />
        public void Set(string comment)
        {
            string  name = "#comment" + commentCount;
            IniItem item = new IniItem(name, null,
                                       IniType.Empty, comment);

            configList.Add(name, item);

            commentCount++;
        }
Exemplo n.º 3
0
        /// <include file='IniSection.xml' path='//Method[@name="GetValue"]/docs/*' />
        public string GetValue(string key)
        {
            string result = null;

            if (Contains(key))
            {
                IniItem item = (IniItem)configList[key];
                result = item.Value;
            }

            return(result);
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        /// <include file='IniSection.xml' path='//Method[@name="GetKeys"]/docs/*' />
        public string[] GetKeys()
        {
            ArrayList 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);
                }
            }
            string[] result = new string[list.Count];
            list.CopyTo(result, 0);

            return(result);
        }