Пример #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;
        }
        public ConfigurationBinder CreateBinder()
        {
            var providers = new MultipleValueProvider(_providers.Reverse().Select(x => x()));

            return new ConfigurationBinderImpl(providers);
        }
Пример #3
0
        public ConfigurationBinder CreateBinder()
        {
            var providers = new MultipleValueProvider(_providers.Reverse().Select(x => x()));

            return(new ConfigurationBinderImpl(providers));
        }