예제 #1
0
        public void Setup()
        {
            _dictionary = new Dictionary<string, object>
                {
                    {"StringValue", "Value"},
                    {"IntValue", "47"},
                    {"Created", "2010-03-01 12:34:56.123"},
                    {"Updated", "2010-03-15 10:34:49.983"},
                    {"Duration", "12:34:56.123"},
                    {"SubClass.Street", "123 American Way"},
                    {"SubClass.City", "Tulsa"},
                    {"SubClass.State", "OK"},
                    //no enum value provided on purpose
                };

            ValueProvider dictionaryProvider = new DictionaryValueProvider(_dictionary);
            ValueProvider jsonProvider = new JsonValueProvider(@"{ Names: [""One"", ""Two"", ""Three""], SubClass: { ZipCode: ""90210"" }, SubClasses: [ { ZipCode: ""68106"" }, { ZipCode: ""68154"" } ] }");

            var providers = new MultipleValueProvider(new[] { dictionaryProvider, jsonProvider });

            ModelBinder binder = new FastModelBinder();
            ModelBinderContext context = new TestModelBinderContext(providers);

            object obj = binder.Bind(typeof(BinderTestClass), context);

            _result = obj as BinderTestClass;
        }
예제 #2
0
        public void Setup()
        {
            _dictionary = new Dictionary <string, object>
            {
                { "StringValue", "Value" },
                { "IntValue", "47" },
                { "Created", "2010-03-01 12:34:56.123" },
                { "Updated", "2010-03-15 10:34:49.983" },
                { "Duration", "12:34:56.123" },
                { "SubClass.Street", "123 American Way" },
                { "SubClass.City", "Tulsa" },
                { "SubClass.State", "OK" },
                //no enum value provided on purpose
            };

            ValueProvider dictionaryProvider = new DictionaryValueProvider(_dictionary);
            ValueProvider jsonProvider       = new JsonValueProvider(@"{ Names: [""One"", ""Two"", ""Three""], SubClass: { ZipCode: ""90210"" }, SubClasses: [ { ZipCode: ""68106"" }, { ZipCode: ""68154"" } ] }");

            var providers = new MultipleValueProvider(new[] { dictionaryProvider, jsonProvider });

            ModelBinder        binder  = new FastModelBinder();
            ModelBinderContext context = new TestModelBinderContext(providers);

            object obj = binder.Bind(typeof(BinderTestClass), context);

            _result = obj as BinderTestClass;
        }
예제 #3
0
        public void Setup()
        {
            _dictionary = new Dictionary <string, object>
            {
                { "StringValue", "Value" },
                { "IntValue", "47" },
                { "Created", "2010-03-01 12:34:56.123" },
                { "Duration", "12:34:56.123" },
                { "SubClass_Street", "123 American Way" },
                { "SubClass_City", "Tulsa" },
                { "SubClass_State", "OK" },
            };

            ModelBinder        binder  = new FastModelBinder();
            ModelBinderContext context = new TestModelBinderContext(_dictionary);

            object obj = binder.Bind(typeof(BinderTestClass), context);

            _result = obj as BinderTestClass;
        }
예제 #4
0
		public void Setup()
		{
			_dictionary = new Dictionary<string, object>
				{
					{"StringValue", "Value"},
					{"IntValue", "47"},
					{"Created", "2010-03-01 12:34:56.123"},
					{"Duration", "12:34:56.123"},
					{"SubClass_Street", "123 American Way"},
					{"SubClass_City", "Tulsa"},
					{"SubClass_State", "OK"},
				};

			ModelBinder binder = new FastModelBinder();
			ModelBinderContext context = new TestModelBinderContext(_dictionary);

			object obj = binder.Bind(typeof (BinderTestClass), context);

			_result = obj as BinderTestClass;
		}