NSoft.NFramework.Nini.Ini.IniSection.GetKeys C# (CSharp) Method

GetKeys() public method

public GetKeys ( ) : string[]
return string[]
        public string[] GetKeys() {
            ArrayList list = new ArrayList();

            for(var i = 0; i < configList.Count; i++) {
                var 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;
        }

Usage Example

示例#1
0
        public void SaveToStream()
        {
            string     filePath = "SaveToStream.ini";
            FileStream stream   = new FileStream(filePath, FileMode.Create);

            // Create a new document and save to stream
            IniDocument doc     = new IniDocument();
            IniSection  section = new IniSection("Pets");

            section.Set("dog", "rover");
            section.Set("cat", "muffy");
            doc.Sections.Add(section);
            doc.Save(stream);
            stream.Close();

            IniDocument newDoc = new IniDocument(new FileStream(filePath,
                                                                FileMode.Open));

            section = newDoc.Sections["Pets"];
            Assert.IsNotNull(section);
            Assert.AreEqual(2, section.GetKeys().Length);
            Assert.AreEqual("rover", section.GetValue("dog"));
            Assert.AreEqual("muffy", section.GetValue("cat"));

            stream.Close();

            File.Delete(filePath);
        }
All Usage Examples Of NSoft.NFramework.Nini.Ini.IniSection::GetKeys