private void LoadProperties()
            {
                InitDefaults();

                if (mpi_file == null)
                {
                    return;
                }

                if (mpi_file.HasGroup(StorageGroup))
                {
                    if (mpi_file.HasKey(StorageGroup, "FolderDepth"))
                    {
                        FolderDepth = mpi_file.GetInteger(StorageGroup, "FolderDepth");
                    }

                    if (mpi_file.HasKey(StorageGroup, "PlaylistPath"))
                    {
                        PlaylistPath = mpi_file.GetString(StorageGroup, "PlaylistPath");
                    }

                    if (mpi_file.HasKey(StorageGroup, "AudioFolders"))
                    {
                        AudioFolders = mpi_file.GetStringList(StorageGroup, "AudioFolders");
                    }
                }

                if (mpi_file.HasGroup(MediaGroup))
                {
                    if (mpi_file.HasKey(MediaGroup, "InputFormats"))
                    {
                        InputFormats = mpi_file.GetStringList(MediaGroup, "InputFormats");
                    }

                    if (mpi_file.HasKey(MediaGroup, "OutputFormats"))
                    {
                        OutputFormats = mpi_file.GetStringList(MediaGroup, "OutputFormats");
                    }
                }

                if (mpi_file.HasGroup(PlaylistGroup) && mpi_file.HasKey(PlaylistGroup, "Formats"))
                {
                    PlaylistFormats = mpi_file.GetStringList(PlaylistGroup, "Formats") ?? new string [] {};
                }

                if (mpi_file.HasGroup(DeviceGroup) && mpi_file.HasKey(DeviceGroup, "AccessProtocols"))
                {
                    AccessProtocols = mpi_file.GetStringList(DeviceGroup, "AccessProtocols") ?? new string [] {};
                }
            }
예제 #2
0
    public void GetNonstandardSeperatorStringList()
    {
        GKeyFile keyFile = new GKeyFile(test_file_name);

        string [] expected = new string [] { "one one", "two", "threee", "for" };
        keyFile.ListSeparator = ':';

        CollectionAssert.AreEqual(expected, keyFile.GetStringList("Group1", "NonSemicolonStringList"));
    }
예제 #3
0
    public void GetStringList()
    {
        string [] expected = new string [] { "one", "two", "three", "four" };

        CollectionAssert.AreEqual(expected, test_keyfile.GetStringList("Group1", "StringList"));
    }
예제 #4
0
    static void Main()
    {
        GKeyFile key_file = new GKeyFile();

        key_file.SetComment(null, null, String.Format("This file was autogenerated by sample.cs on {0}", DateTime.Now));
        key_file.SetString("General", "sKey0", "that's the string value associated to the sKey0");
        key_file.SetComment("General", null, "A comment for the General group");
        key_file.SetComment("General", "sKey0", "A comment for the sKey0 key");
        key_file.SetStringList("Lists", "sList", new string [] { "item0", "item1", "item2", "lastitem" });
        key_file.SetBoolean("SingleValues", "aBool", true);
        key_file.SetBoolean("SingleValues", "anotherBool", false);
        key_file.SetString("SingleValues", "aString", "this is _not_ a string");
        key_file.SetInteger("SingleValues", "anInt", 42);
        key_file.SetDouble("SingleValues", "aDouble", Math.PI);
        key_file.SetComment("SingleValues", "aDouble", "Change this at the time the square became the new circle");
        key_file.Save("mysamplefile.ini");

        key_file = new GKeyFile("mysamplefile.ini");
        key_file.RemoveComment("SingleValues", "aDouble");
        key_file.SetBooleanList("Lists", "bools", new bool [] { true, false, false, true });
        key_file.SetIntegerList("Lists", "ints", new int [] { 0, 1, 2, -3, -5 });
        key_file.SetDoubleList("Lists", "doubles", new double [] { Math.PI, Math.Sqrt(2) });

        foreach (string group in key_file.GetGroups())
        {
            Console.WriteLine("\t" + group);
            foreach (string key in key_file.GetKeys(group))
            {
                Console.WriteLine("\t\t" + key);
            }
        }
        Console.WriteLine(key_file.HasGroup("Foo"));
        Console.WriteLine(key_file.HasGroup("General"));
        Console.WriteLine(key_file.HasKey("General", "sKey0"));
        Console.WriteLine(key_file.HasKey("General", "sKey1"));
        try {
            key_file.GetValue("foo", "bar");
        } catch (GLib.GException e) {
            Console.WriteLine(e);
        }
        foreach (string val in key_file.GetStringList("Lists", "sList"))
        {
            Console.WriteLine(val);
        }

        foreach (int i in key_file.GetIntegerList("Lists", "ints"))
        {
            Console.WriteLine(i);
        }

        foreach (double d in key_file.GetDoubleList("Lists", "doubles"))
        {
            Console.WriteLine(d);
        }

        foreach (bool b in key_file.GetBooleanList("Lists", "bools"))
        {
            Console.WriteLine(b);
        }

        key_file.Save("mysamplefile2.ini");

        key_file = new GKeyFile("mysamplefile.ini");
        key_file.RemoveGroup("General");
        key_file.Save("mysamplefile3.ini");
    }