本文整理汇总了C#中Configuration.Read方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.Read方法的具体用法?C# Configuration.Read怎么用?C# Configuration.Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.Read方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStringValueTest
public void GetStringValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
Assert.AreEqual("127.0.0.1", config.GetString("ssh_client.connection.host"));
Assert.AreEqual("http://localhost", config.GetString("ssh_client.connection.url", "http://localhost"));
}
示例2: ReadTest
public void ReadTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
Assert.IsTrue(config.HasPath("ssh_client"));
Assert.IsTrue(config.HasPath("ssh_client.connection"));
Assert.IsTrue(config.HasValue("ssh_client.connection.host"));
Assert.IsTrue(config.HasValue("ssh_client.connection.port"));
Assert.IsTrue(config.HasValue("ssh_client.status"));
}
示例3: GetDecimalValueTest
public void GetDecimalValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
Assert.AreEqual(3.14m, config.GetDecimal("math.pi"));
Assert.AreEqual(2.718m, config.GetDecimal("math.e", 2.718m));
}
示例4: GetIntValueTest
public void GetIntValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
Assert.AreEqual(22, config.GetInt("ssh_client.connection.port"));
Assert.AreEqual(8080, config.GetInt("web_client.port", 8080));
}
示例5: NegativeCase1Test
public void NegativeCase1Test()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
config.GetString("sources.o_array");
}
示例6: NegativeCase3Test
public void NegativeCase3Test()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
config.GetValueList("ssh_client.connection.host");
}
示例7: GetBoolListValueTest
public void GetBoolListValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
var value = config.GetBoolList("sources.b_array");
Assert.AreEqual(2, value.Count);
Assert.AreEqual(true, value[0]);
Assert.AreEqual(false, value[1]);
value = config.GetBoolList("sources.b_array_dummy", new List<bool> { false, true, false });
Assert.AreEqual(3, value.Count);
Assert.AreEqual(false, value[0]);
Assert.AreEqual(true, value[1]);
Assert.AreEqual(false, value[2]);
}
示例8: GetObjectListValueTest
public void GetObjectListValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
var value = config.GetValueList("sources.o_array");
Assert.AreEqual(3, value.Count);
Assert.AreEqual(1, value[0]);
Assert.AreEqual(3.14m, value[1]);
Assert.AreEqual("hello", value[2]);
value = config.GetValueList("sources.o_array_dummy", new List<object> { "first", true, 1 });
Assert.AreEqual(3, value.Count);
Assert.AreEqual("first", value[0]);
Assert.AreEqual(true, value[1]);
Assert.AreEqual(1, value[2]);
}
示例9: GetDecimalListValueTest
public void GetDecimalListValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
var value = config.GetDecimalList("sources.d_array");
Assert.AreEqual(2, value.Count);
Assert.AreEqual(3.14m, value[0]);
Assert.AreEqual(2.0m, value[1]);
value = config.GetDecimalList("sources.d_array_dummy", new List<decimal> { 333.222m });
Assert.AreEqual(1, value.Count);
Assert.AreEqual(333.222m, value[0]);
}
示例10: GetIntListValueTest
public void GetIntListValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
var value = config.GetIntList("sources.i_array");
Assert.AreEqual(2, value.Count);
Assert.AreEqual(1024, value[0]);
Assert.AreEqual(2048, value[1]);
value = config.GetIntList("sources.i_array_dummy", new List<int> { 333 });
Assert.AreEqual(1, value.Count);
Assert.AreEqual(333, value[0]);
}
示例11: GetStringListValueTest
public void GetStringListValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
var value = config.GetStringList("sources.s_array");
Assert.AreEqual(2, value.Count);
Assert.AreEqual("first", value[0]);
Assert.AreEqual("second", value[1]);
value = config.GetStringList("sources.s_array_dummy", new List<string>{"s1"});
Assert.AreEqual(1, value.Count);
Assert.AreEqual("s1", value[0]);
}
示例12: GetObjectValueTest
public void GetObjectValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
var value = config.GetValue("ssh_client.status");
Assert.IsTrue(value is bool);
Assert.AreEqual(true, value);
value = config.GetValue("ssh_client.welcomeMessage");
Assert.AreEqual(null, value);
}
示例13: GetBoolValueTest
public void GetBoolValueTest()
{
var config = new Configuration(_ => ConfigSource);
config.Read("main");
Assert.AreEqual(true, config.GetBool("ssh_client.status"));
Assert.AreEqual(true, config.GetBool("ssh_client.logging", true));
}