当前位置: 首页>>代码示例>>C#>>正文


C# AppSettings.HasAppSetting方法代码示例

本文整理汇总了C#中AppSettings.HasAppSetting方法的典型用法代码示例。如果您正苦于以下问题:C# AppSettings.HasAppSetting方法的具体用法?C# AppSettings.HasAppSetting怎么用?C# AppSettings.HasAppSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AppSettings的用法示例。


在下文中一共展示了AppSettings.HasAppSetting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Then_property_is_ignored

        public void Then_property_is_ignored()
        {
            var settings = new AppSettings("filename", FileOption.None);
            var mySettings = new Settings(100);

            settings.ReadFrom(mySettings);

            Assert.IsFalse(settings.HasAppSetting("IntValue"));
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:9,代码来源:When_both_IgnoreAndSetting_are_defined.cs

示例2: Then_read_and_write_should_succeed

        public void Then_read_and_write_should_succeed()
        {
            var fileName = Guid.NewGuid() + ".config";
            var fullPathToConfigurationFile = TestHelpers.GetFullPathToConfigurationFile(fileName);

            try
            {
                var settings = new AppSettings(fullPathToConfigurationFile, FileOption.None);
                var mySettings = new TempSettings()
                    {
                        NonEmptyStringValue = "aaa",
                        IntValue = 123,
                        DoubleValue = 123.12d,
                        LocalizedValue = 456.789
                    };

                settings.ReadFrom(mySettings);

                Assert.AreEqual("aaa", settings.GetValue("NonEmptyStringValue"));
                Assert.IsFalse(settings.HasAppSetting("IntValue"));
                Assert.AreEqual(null, settings.GetValue<int?>("EmptyIntValue"));
                Assert.AreEqual(123.12d, settings.GetValue<double>("DoubleValue"));
                Assert.AreEqual(456.789, settings.GetValue<double>("DoubleFinnishLocale", CultureInfo.GetCultureInfo("fi-FI")));
                Assert.AreEqual("456,789", settings.GetValue("DoubleFinnishLocale"));

                settings.Save();

                var otherSettings = new TempSettings();
                settings.WriteInto(otherSettings);

                Assert.AreEqual("aaa", otherSettings.NonEmptyStringValue);
                Assert.AreEqual(0, otherSettings.IntValue);
                Assert.AreEqual(null, otherSettings.NullableIntValue);
                Assert.AreEqual(123.12d, otherSettings.DoubleValue);
                Assert.AreEqual(456.789, otherSettings.LocalizedValue);
            }
            finally
            {
                TestHelpers.DeleteIfExists(fullPathToConfigurationFile);
            }
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:41,代码来源:When_using_ReadFrom_and_WriteInto.cs

示例3: Then_write_only_properties_should_be_skipped

        public void Then_write_only_properties_should_be_skipped()
        {
            var settings = new AppSettings("filename", FileOption.None);
            var mySettings = new SettingsWithWriteOnlyProperty();
            mySettings.NonEmptyStringValue = "abc";

            settings.ReadFrom(mySettings);

            Assert.AreEqual("abc", settings.GetValue("NonEmptyStringValue"));
            Assert.IsFalse(settings.HasAppSetting("DoubleValue"));
        }
开发者ID:tparvi,项目名称:appsettings,代码行数:11,代码来源:When_reading_from_public_properties.cs


注:本文中的AppSettings.HasAppSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。