コード例 #1
0
        public void XmlConfigSetItemAndAddItem_ValueSet()
        {
            #region arrange - given

            var config = new XmlConfig();
            var settingsShouldMatchThis = new[]
            {
                new[] { "Item1", "Value1" },
                new[] { "Item2", "Value2" },
                new[] { "Item3", "Value3" }
            };

            #endregion

            #region act - when

            SetItemValues(config);

            // Xml Serialization requires IEnumerables implement Add
            config.Add(new ConfigSetting {
                Name = "Item3", Value = "Value3"
            });

            #endregion

            #region assert - then

            AssertConfigurationIsValid(config, settingsShouldMatchThis,
                                       "Xml configuration did not set values properly.");

            #endregion
        }
コード例 #2
0
        public void SaveProfile(Profile profile)
        {
            if (profile.New)
            {
                profile.New = false;
                Profiles.Add(profile);
                XmlConfig.Add(profile.ProfileXml);
            }

            //if we have no default, make it this one
            if (string.IsNullOrEmpty(DefaultProfileId))
            {
                DefaultProfileId = profile.ProfileId;
                CurrentProfile   = profile;
            }

            XmlConfig.Save(PROFILES_XML);
        }