本文整理匯總了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);
}