예제 #1
0
		public void MoveToNextSection ()
		{
			StringWriter writer = new StringWriter ();
			writer.WriteLine ("; Test");
			writer.WriteLine ("; Test 1");
			writer.WriteLine ("[Nini Thing]");
			IniReader reader = new IniReader (new StringReader (writer.ToString ()));
			
			Assert.IsTrue (reader.MoveToNextSection ());
			Assert.AreEqual (4, reader.LineNumber);
			Assert.AreEqual (IniType.Section, reader.Type);
			Assert.IsFalse (reader.MoveToNextSection ());
		}
예제 #2
0
        /// <summary>
        /// Load control bindings from an arbitrary stream.
        /// If there are already bindings, the new ones will be added.
        /// New bindings overwrite old bindings.
        /// </summary>
        /// <param name="file">The source of the INI data</param>
        public void LoadConfiguration(Stream file)
        {
            using (IniReader r = new IniReader(file))
            {
                while (true)
                {
                    if (r.Type != IniType.Section)
                    {
                        if (!r.MoveToNextSection())
                            break;
                    }
                    String[] parts = r.Name.Split(' ');
                    if (parts[0] == "KeyBindings")
                    {
                        if (parts.Length > 1)
                        {
                            ControlState cs = rootcstate.GetChild(parts[1], true);
                            cs.ReadIni(r);
                        }
                        else
                        {
                            rootcstate.ReadIni(r);
                        }
                    }
                    /*else if (parts[0] == "MouseButtons")
                    {
                    }*/
                    else if (parts[0] == "WindowEvents")
                    {
                        while (r.Read())
                        {
                            if (r.Type == IniType.Section)
                                break;

                            if (r.Type == IniType.Key)
                                winEvents[r.Name] = r.Value;
                        }
                    }
                    else
                        r.MoveToNextSection();
                }
            }
        }