本文整理汇总了C#中Binder.BindTo方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.BindTo方法的具体用法?C# Binder.BindTo怎么用?C# Binder.BindTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Binder
的用法示例。
在下文中一共展示了Binder.BindTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: can_bind_property_to_A_using_different_name_from_attribute
public void can_bind_property_to_A_using_different_name_from_attribute()
{
var binder = new Binder<A>();
var pairs = new KeyValuePair<string, string>[]{
new KeyValuePair<string,string>("AnIntegerV2","4")
};
var a = binder.BindTo(pairs);
Assert.AreEqual(4, a.AStringCustoName);
}
示例2: can_bind_to_int_and_string_prop_and_field_of_A
public void can_bind_to_int_and_string_prop_and_field_of_A()
{
var binder = new Binder();
var pairs = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("AnInteger","2"),
new KeyValuePair<string, string>("AString","abc")
};
var a = binder.BindTo<A>(pairs);
Assert.AreEqual(2, a.AnInteger);
Assert.AreEqual("abc", a.AString);
}
示例3: can_bind_property_to_A_using_attribute
public void can_bind_property_to_A_using_attribute()
{
var binder = new Binder<A>();
var pairs = new KeyValuePair<string, string>[]{
new KeyValuePair<string,string>("AnInteger","2"),
new KeyValuePair<string,string>("AString","abc")
};
var a = binder.BindTo(pairs);
Assert.AreEqual(2, a.AnInteger);
Assert.AreEqual("abc", a.AString);
}
示例4: test
public void test()
{
var binder = new Binder();
var pairs = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("AnInteger", "2"),
new KeyValuePair<string, string>("AString", "abc"),
new KeyValuePair<string, string>("APoint", "1,2"),
};
var exc = Assert.Throws<InvalidMemberTypeException>(() => binder.BindTo<B>(pairs));
Assert.AreEqual(typeof(B).GetField("APoint"), exc.MemberInfo);
}
示例5: can_bind_to_A
public void can_bind_to_A()
{
var binder = new Binder();
var pairs = new KeyValuePair<string, string>[]
{
new KeyValuePair<string,string> ("AnInteger", "2"),
new KeyValuePair<string, string>("AString","123")
};
var a = binder.BindTo<A>(pairs);
Assert.AreEqual(2, a.AnInteger);
Assert.AreEqual("123", a.AString);
}
示例6: when_member_has_invalid_type_then_BindTo_throws
public void when_member_has_invalid_type_then_BindTo_throws()
{
var binder = new Binder();
var pairs = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("AnInteger","2"),
new KeyValuePair<string, string>("AString","abc"),
new KeyValuePair<string, string>("APoint","1,2")
};
var exc = Assert.Throws<InvalidMemberTypeException>(() =>
binder.BindTo<B>(pairs)
);
Assert.AreEqual(typeof(B).GetProperty("APoint"),exc.MemberInfo);
}
示例7: cand_bind_only_to_bindable_fields_or_properties_that_are_required
public void cand_bind_only_to_bindable_fields_or_properties_that_are_required()
{
var binder = new Binder();
var pairs = new KeyValuePair<string, string>[]
{
new KeyValuePair<string, string>("AnInteger", "2"),
new KeyValuePair<string, string>("AString", "abc")
};
var a = binder.BindTo<C>(pairs);
Assert.AreEqual(default(Int32), a.AnInteger);
Assert.AreEqual(default(String), a.AString);
}