当前位置: 首页>>代码示例>>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;未经允许,请勿转载。