當前位置: 首頁>>代碼示例>>C#>>正文


C# Binder.BindTo2方法代碼示例

本文整理匯總了C#中Binder.BindTo2方法的典型用法代碼示例。如果您正苦於以下問題:C# Binder.BindTo2方法的具體用法?C# Binder.BindTo2怎麽用?C# Binder.BindTo2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Binder的用法示例。


在下文中一共展示了Binder.BindTo2方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: can_bind2_to_string_int_and_bool

        public void can_bind2_to_string_int_and_bool()
        {
            var binder = new Binder();
            var pairs = new KeyValuePair<string, string>[]
            {
                new KeyValuePair<string,string> ("AnInteger", "2"),
                new KeyValuePair<string, string>("AString","123"),
                new KeyValuePair<string, string>("AFlag","true")
            };
            var a = binder.BindTo2<A>(pairs);

            Assert.AreEqual(2, a.TheInteger);
            Assert.AreEqual("123", a.TheString);
            Assert.AreEqual(true, a.TheFlag);
        }
開發者ID:sandrapatfer,項目名稱:PROMPT11-01-VMEssentials.sandrapatfer,代碼行數:15,代碼來源:BindingTests.cs

示例2: bind2_when_member_is_required_throws_exception

 public void bind2_when_member_is_required_throws_exception()
 {
     var binder = new Binder();
     var pairs = new KeyValuePair<string, string>[]
     {
         new KeyValuePair<string,string> ("AttrInteger", "2")
     };
     try
     {
         var b = binder.BindTo2<B>(pairs);
     }
     catch (RequiredMemberException ex)
     {
         Assert.AreEqual("AString", ex.MemberName);
         throw ex;
     }
 }
開發者ID:sandrapatfer,項目名稱:PROMPT11-01-VMEssentials.sandrapatfer,代碼行數:17,代碼來源:BindingTests.cs

示例3: bind2_convert_point

 public void bind2_convert_point()
 {
     var binder = new Binder();
     binder.WithConverterFor<Point>(new PointConverter());
     var pairs = new KeyValuePair<string, string>[]
     {
         new KeyValuePair<string,string> ("AttrInteger", "2"),
         new KeyValuePair<string, string>("AttrString","123"),
         new KeyValuePair<string, string>("AttrPoint","1,2")
     };
     
     var b = binder.BindTo2<B>(pairs);
     Assert.AreEqual(2, b.AnInteger);
     Assert.AreEqual("123", b.AString);
     Assert.AreEqual(1, b.ThePoint.X);
     Assert.AreEqual(2, b.ThePoint.Y);
 }
開發者ID:sandrapatfer,項目名稱:PROMPT11-01-VMEssentials.sandrapatfer,代碼行數:17,代碼來源:BindingTests.cs

示例4: bind2_when_member_has_invalid_type_throws_exception

 public void bind2_when_member_has_invalid_type_throws_exception()
 {
     var binder = new Binder();
     var pairs = new KeyValuePair<string, string>[]
     {
         new KeyValuePair<string,string> ("AttrInteger", "2"),
         new KeyValuePair<string, string>("AttrString","123"),
         new KeyValuePair<string, string>("AttrPoint","1,2")
     };
     try
     {
         var b = binder.BindTo2<B>(pairs);
     }
     catch (InvalidMemberTypeException ex)
     {
         Assert.AreEqual(typeof(B).GetField("ThePoint"), ex.MemberInfo);
         Assert.AreEqual(typeof(B).GetField("ThePoint").FieldType, ex.MemberType);
         throw ex;
     }
 }
開發者ID:sandrapatfer,項目名稱:PROMPT11-01-VMEssentials.sandrapatfer,代碼行數:20,代碼來源:BindingTests.cs


注:本文中的Binder.BindTo2方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。