public object Resolve(Accessor accessor, string value)
        {
            var values = new Dictionary <string, string> {
                { accessor.Name, value }
            };

            return(_resolver.BindModel(accessor.OwnerType, new FlatValueSource(values)).Value);
        }
Exemplo n.º 2
0
        public T BindToHeaders <T>()
        {
            var bindResult = _resolver.BindModel <T>(_values);

            bindResult.AssertNoProblems(typeof(T));

            return((T)bindResult.Value);
        }
Exemplo n.º 3
0
        public object Read(Type type, ObjectBlock block)
        {
            var settings = _blocks.SettingsFor(type);

            block.MakeCollections(settings);
            var result = _resolver.BindModel(type, new ObjectBlockValues(block, settings, type));

            return(result.Value);
        }
Exemplo n.º 4
0
        public static T Bind <T>(this IObjectResolver resolver, IDictionary <string, object> dictionary)
        {
            var source = new SettingsData(dictionary);
            var result = resolver.BindModel(typeof(T), source);

            result.AssertNoProblems(typeof(T));

            return((T)result.Value);
        }
Exemplo n.º 5
0
        public T BindToHeaders <T>()
        {
            var data       = _dictionary.DataFor(RequestDataSource.Header.ToString());
            var bindResult = _resolver.BindModel(typeof(T), data);

            bindResult.AssertNoProblems(typeof(T));

            return((T)bindResult.Value);
        }
Exemplo n.º 6
0
        public object SettingsFor(Type settingsType)
        {
            var prefixedData = createRequestData(settingsType);

            var result = _resolver.BindModel(settingsType, prefixedData);

            result.AssertNoProblems(settingsType);

            return(result.Value);
        }
        public object SettingsFor(Type settingsType)
        {
            var requestData = new RequestData(_values.Value.GetChild(settingsType.Name));

            var result = _resolver.BindModel(settingsType, requestData);

            result.AssertNoProblems(settingsType);

            return(result.Value);
        }
Exemplo n.º 8
0
        public object SettingsFor(Type settingsType)
        {
            var settingsData = new SettingsRequestData(_sources.SelectMany(x => x.FindSettingData()));
            var prefixedData = new PrefixedRequestData(settingsData, settingsType.Name + ".");

            var result = _resolver.BindModel(settingsType, prefixedData);

            result.AssertNoProblems(settingsType);

            return(result.Value);
        }
Exemplo n.º 9
0
        public object SettingsFor(Type settingsType)
        {
            IBindingContext context = new BindingContext(new AppSettingsRequestData(), _locator)
                                      .PrefixWith(settingsType.Name + ".");

            BindResult result = _resolver.BindModel(settingsType, context);

            result.AssertNoProblems(settingsType);

            return(result.Value);
        }
Exemplo n.º 10
0
        private void processData <T>(TextReader reader, CsvData headers, CsvRequest <T> request)
        {
            var mapping = request.Mapping.As <IColumnMapping>();

            readUntilComplete(reader, tokens =>
            {
                var source = valueSourceFor(tokens, headers, mapping);
                var result = _resolver.BindModel(typeof(T), source);

                request.Callback(result.Value.As <T>());
                return(true);
            });
        }
Exemplo n.º 11
0
        public static BindResult BindModel <T>(this IObjectResolver resolver, IValueSource values)
        {
            var requestData = new RequestData(values);

            return(resolver.BindModel(typeof(T), requestData));
        }
Exemplo n.º 12
0
 public FubuRequest(IRequestData data, IObjectResolver resolver)
 {
     _values.OnMissing = (type => resolver.BindModel(type, data));
 }
Exemplo n.º 13
0
        public T Read(string mimeType)
        {
            var result = _resolver.BindModel(typeof(T), _context);

            return((T)result.Value);
        }
Exemplo n.º 14
0
        public T ReadFromJson(string json)
        {
            var values = new JObjectValues(json);

            return((T)_resolver.BindModel(typeof(T), values).Value);
        }