Esempio n. 1
0
        public SelfHostRequestData(RouteData routeData, HttpRequestMessage request, ICookies cookies)
        {
            AddValues(new RouteDataValues(routeData));



            var querystring = request.RequestUri.ParseQueryString();

            AddValues("Querystring", new NamedKeyValues(querystring));

            var formData = request.Content.IsFormData() ? request.Content.ReadAsFormDataAsync().Result : new NameValueCollection();

            AddValues(RequestDataSource.Request.ToString(), new NamedKeyValues(formData));

            var headers = AggregateKeyValues.For(new HeaderKeyValues(request.Headers),
                                                 new HeaderKeyValues(request.Content.Headers));

            AddValues(RequestDataSource.Header.ToString(), headers);

            Func <string, IEnumerable <string>, bool> ignoreCaseKeyFinder = (key, keys) => keys.Contains(key, StringComparer.InvariantCultureIgnoreCase);
            var values      = new SimpleKeyValues(key => cookies.Get(key).Value, () => cookies.Request.Select(x => x.Name), ignoreCaseKeyFinder);
            var valueSource = new FlatValueSource <object>(values, RequestDataSource.Cookie.ToString());

            AddValues(valueSource);
        }
Esempio n. 2
0
        private void addValues(RequestDataSource source, Func<string, object> finder, Func<IEnumerable<string>> findKeys)
        {
            var values = new SimpleKeyValues(finder, findKeys);
            var valueSource = new FlatValueSource(values, source.ToString());

            //var valueSource = new GenericValueSource(source.ToString(), finder, findKeys);
            AddValues(valueSource);
        }
Esempio n. 3
0
        private void addValues(RequestDataSource source, Func <string, object> finder, Func <IEnumerable <string> > findKeys, Func <string, IEnumerable <string>, bool> keyFinder = null)
        {
            Func <string, IEnumerable <string>, bool> defaultKeyFinder = (key, keys) => keys.Contains(key);

            var values      = new SimpleKeyValues(finder, findKeys, keyFinder ?? defaultKeyFinder);
            var valueSource = new FlatValueSource <object>(values, source.ToString());

            AddValues(valueSource);
        }
        public void SetUp()
        {
            theDictionary = new Dictionary <string, string>();

            theValues = new FlatValueSource(theDictionary, "some name");

            theDictionary.Add("ChildProp1", "1");
            theDictionary.Add("ChildProp2", "2");
            theDictionary.Add("ChildProp3", "3");
            theDictionary.Add("ChildProp4", "4");
            theDictionary.Add("ChildDescProp1", "123");

            child = theValues.GetChild("Child");
        }
Esempio n. 5
0
 public void AddValues(string name, IKeyValues values)
 {
     var source = new FlatValueSource(values, name);
     _sources.Add(source);
 }
Esempio n. 6
0
        public void SetUp()
        {
            theDictionary = new Dictionary<string, string>();

            theValues = new FlatValueSource(theDictionary, "some name");
        }
Esempio n. 7
0
        public void SetUp()
        {
            theDictionary = new Dictionary<string, string>();

            theValues = new FlatValueSource(theDictionary, "some name");

            theDictionary.Add("ChildProp1", "1");
            theDictionary.Add("ChildProp2", "2");
            theDictionary.Add("ChildProp3", "3");
            theDictionary.Add("ChildProp4", "4");
            theDictionary.Add("ChildDescProp1", "123");

            child = theValues.GetChild("Child");
        }
        public void SetUp()
        {
            theDictionary = new Dictionary <string, string>();

            theValues = new FlatValueSource(theDictionary, "some name");
        }
Esempio n. 9
0
        public void AddValues(string name, IKeyValues values)
        {
            var source = new FlatValueSource(values, name);

            _sources.Add(source);
        }
Esempio n. 10
0
        public SelfHostRequestData(RouteData routeData, HttpRequestMessage request, ICookies cookies)
        {
            AddValues(new RouteDataValues(routeData));

            var querystring = request.RequestUri.ParseQueryString();
            AddValues("Querystring", new NamedKeyValues(querystring));

            var formData = request.Content.IsFormData() ? request.Content.ReadAsFormDataAsync().Result : new NameValueCollection();

            AddValues(RequestDataSource.Request.ToString(), new NamedKeyValues(formData));

            var headers = AggregateKeyValues.For(new HeaderKeyValues(request.Headers),
                                                 new HeaderKeyValues(request.Content.Headers));
            AddValues(RequestDataSource.Header.ToString(), headers);

            Func<string, IEnumerable<string>, bool> ignoreCaseKeyFinder = (key, keys) => keys.Contains(key, StringComparer.InvariantCultureIgnoreCase);
            var values = new SimpleKeyValues(key => cookies.Get(key).Value, () => cookies.Request.Select(x => x.Name), ignoreCaseKeyFinder);
            var valueSource = new FlatValueSource<object>(values, RequestDataSource.Cookie.ToString());

            AddValues(valueSource);
        }