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


C# Binder.BindTo方法代碼示例

本文整理匯總了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);
        }
開發者ID:vilhena,項目名稱:PROMPT11-01-VMEssentials.vilhena,代碼行數:11,代碼來源:Problem2.cs

示例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);
        }
開發者ID:cmfaustino,項目名稱:Prompt11-01-VMEssentials.cmfaustino,代碼行數:13,代碼來源:BinderTests.cs

示例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);
        }
開發者ID:vilhena,項目名稱:PROMPT11-01-VMEssentials.vilhena,代碼行數:13,代碼來源:Problem2.cs

示例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);
        }
開發者ID:luismdcp,項目名稱:PROMPT11-01-VMEssentials.luismdcp,代碼行數:13,代碼來源:Class1.cs

示例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);
        }
開發者ID:sandrapatfer,項目名稱:PROMPT11-01-VMEssentials.sandrapatfer,代碼行數:13,代碼來源:BindingTests.cs

示例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);
 }
開發者ID:cmfaustino,項目名稱:Prompt11-01-VMEssentials.cmfaustino,代碼行數:14,代碼來源:BinderTests.cs

示例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);
        }
開發者ID:luismdcp,項目名稱:PROMPT11-01-VMEssentials.luismdcp,代碼行數:14,代碼來源:Class1.cs


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