本文整理汇总了C#中ConfigurationBuilder.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigurationBuilder.Bind方法的具体用法?C# ConfigurationBuilder.Bind怎么用?C# ConfigurationBuilder.Bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigurationBuilder
的用法示例。
在下文中一共展示了ConfigurationBuilder.Bind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldBePreserved
public void ShouldBePreserved()
{
var source = new TestSource
{
Foo = "Foobar",
Bar = 32,
Child = new TestEmbedded
{
Blah = "o hai",
Qux = 64
}
};
var compiled = new ConfigurationBuilder()
.AddObject(source)
.Build();
var dest = new TestTarget();
compiled.Bind(dest);
dest.Foo.Should().Be("Foobar");
dest.Bar.Should().Be(32);
dest.Child.Blah.Should().Be("o hai");
dest.Child.Qux.Should().Be(64);
}
示例2: ShouldIgnoreUnknownFields
public void ShouldIgnoreUnknownFields()
{
var source = new TestSource
{
Foo = "Foobar",
Bar = 32,
IgnoredSource = "NOPE"
};
var compiled = new ConfigurationBuilder()
.AddObject(source)
.Build();
var dest = new TestTarget();
compiled.Bind(dest);
dest.IgnoredDest.Should().BeNullOrEmpty();
}