本文整理汇总了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"));
}
示例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);
}
}
示例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"));
}