コード例 #1
0
        public void SaveAndLoadTest()
        {
            var newSection = new TestSettingsSectionB();

            newSection.UserList.Add(new TestUser()
            {
                Name  = "Test user 1",
                Id    = NewGuid(),
                Title = TestUserTitle.Mr
            });
            newSection.UserList.Add(new TestUser()
            {
                Name  = "Test user 2",
                Id    = NewGuid(),
                Title = TestUserTitle.Dr
            });
            newSection.UserList.Add(new TestUser()
            {
                Name  = "Test user 3",
                Id    = NewGuid(),
                Title = TestUserTitle.Miss
            });

            SettingsManager saveManager = new SettingsManager(ManagerOptions);

            saveManager.SetSection("test-section", newSection);

            saveManager.SaveSettings();

            SettingsManager loadManager = new SettingsManager(ManagerOptions);

            loadManager.LoadSettings();
            var fetchedSection = loadManager.GetSection <TestSettingsSectionB>("test-section");
        }
コード例 #2
0
        public void SimpleSet()
        {
            SettingsManager manager = new SettingsManager(ManagerOptions);

            var sectionA = new TestSettingsSectionA()
            {
                IntSetting    = 5,
                StringSetting = "Test value"
            };

            var sectionB = new TestSettingsSectionB();

            sectionB.StringList.Add("Value 1");
            sectionB.StringList.Add("Value 2");
            sectionB.StringList.Add("Value 3");
            sectionB.UserList.Add(new TestUser()
            {
                Name  = "Test user 1",
                Id    = NewGuid(),
                Title = TestUserTitle.Mr
            });
            sectionB.UserList.Add(new TestUser()
            {
                Name  = "Test user 2",
                Id    = NewGuid(),
                Title = TestUserTitle.Dr
            });
            sectionB.UserList.Add(new TestUser()
            {
                Name  = "Test user 3",
                Id    = NewGuid(),
                Title = TestUserTitle.Miss
            });

            manager.SetSection(sectionA);
            manager.SetSection(sectionB);
        }