Пример #1
0
        private Dictionary <string, ValueProviderResultPlaceholder> InitializeCollectionValues()
        {
            Dictionary <string, ValueProviderResultPlaceholder> tempValues =
                new Dictionary <string, ValueProviderResultPlaceholder>(StringComparer.OrdinalIgnoreCase);

            // Need to read keys from the unvalidated collection, as M.W.I's granular request validation is a bit touchy
            // and validated entries at the time the key or value is looked at. For example, GetKey() will throw if the
            // value fails request validation, even though the value's not being looked at (M.W.I can't tell the difference).

            foreach (string key in _unvalidatedCollection)
            {
                if (key != null)
                {
                    string normalizedKey = key;
                    if (_jQueryToMvcRequestNormalizationRequired)
                    {
                        normalizedKey = NormalizeJQueryToMvc(key);
                    }

                    // need to look up values lazily, as eagerly looking at the collection might trigger validation
                    tempValues[normalizedKey] =
                        new ValueProviderResultPlaceholder(key, _collection, _unvalidatedCollection, _culture);
                }
            }

            return(tempValues);
        }
        internal CookieValueProvider(HttpCookieCollection collection, HttpCookieCollection unvalidatedCollection, CultureInfo culture) {
            if (collection == null) {
                throw new ArgumentNullException("collection");
            }

            _culture = culture;
            _prefixes = new PrefixContainer(collection.Keys.Cast<string>());
            _validatedCollection = collection;
            _unvalidatedCollection = unvalidatedCollection ?? collection;

            foreach (string key in collection) {
                if (key != null) {
                    _values[key] = new ValueProviderResultPlaceholder(key, this);
                }
            }
        }
        private void AddValues(NameValueCollection validatedCollection, NameValueCollection unvalidatedCollection, CultureInfo culture) {
            // Need to read keys from the unvalidated collection, as M.W.I's granular request validation is a bit touchy
            // and validated entries at the time the key or value is looked at. For example, GetKey() will throw if the
            // value fails request validation, even though the value's not being looked at (M.W.I can't tell the difference).

            if (unvalidatedCollection.Count > 0) {
                _prefixes.Add("");
            }

            foreach (string key in unvalidatedCollection) {
                if (key != null) {
                    _prefixes.UnionWith(ValueProviderUtil.GetPrefixes(key));

                    // need to look up values lazily, as eagerly looking at the collection might trigger validation
                    _values[key] = new ValueProviderResultPlaceholder(key, validatedCollection, unvalidatedCollection, culture);
                }
            }
        }
Пример #4
0
        internal CookieValueProvider(HttpCookieCollection collection, HttpCookieCollection unvalidatedCollection, CultureInfo culture)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            _culture               = culture;
            _prefixes              = new PrefixContainer(collection.Keys.Cast <string>());
            _validatedCollection   = collection;
            _unvalidatedCollection = unvalidatedCollection ?? collection;

            foreach (string key in collection)
            {
                if (key != null)
                {
                    _values[key] = new ValueProviderResultPlaceholder(key, this);
                }
            }
        }
        public NameValueCollectionValueProvider(NameValueCollection collection, NameValueCollection unvalidatedCollection, CultureInfo culture)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            unvalidatedCollection = unvalidatedCollection ?? collection;

            // Need to read keys from the unvalidated collection, as M.W.I's granular request validation is a bit touchy
            // and validated entries at the time the key or value is looked at. For example, GetKey() will throw if the
            // value fails request validation, even though the value's not being looked at (M.W.I can't tell the difference).

            foreach (string key in unvalidatedCollection)
            {
                if (key != null)
                {
                    // need to look up values lazily, as eagerly looking at the collection might trigger validation
                    _values[key] = new ValueProviderResultPlaceholder(key, collection, unvalidatedCollection, culture);
                }
            }
        }
Пример #6
0
        public NameValueCollectionValueProvider(NameValueCollection collection, NameValueCollection unvalidatedCollection, CultureInfo culture)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }

            unvalidatedCollection = unvalidatedCollection ?? collection;

            // Need to read keys from the unvalidated collection, as M.W.I's granular request validation is a bit touchy
            // and validated entries at the time the key or value is looked at. For example, GetKey() will throw if the
            // value fails request validation, even though the value's not being looked at (M.W.I can't tell the difference).

            foreach (string key in unvalidatedCollection)
            {
                if (key != null)
                {
                    // need to look up values lazily, as eagerly looking at the collection might trigger validation
                    _values[key] = new ValueProviderResultPlaceholder(key, collection, unvalidatedCollection, culture);
                }
            }
        }
Пример #7
0
        private void AddValues(NameValueCollection validatedCollection, NameValueCollection unvalidatedCollection, CultureInfo culture)
        {
            // Need to read keys from the unvalidated collection, as M.W.I's granular request validation is a bit touchy
            // and validated entries at the time the key or value is looked at. For example, GetKey() will throw if the
            // value fails request validation, even though the value's not being looked at (M.W.I can't tell the difference).

            if (unvalidatedCollection.Count > 0)
            {
                _prefixes.Add("");
            }

            foreach (string key in unvalidatedCollection)
            {
                if (key != null)
                {
                    _prefixes.UnionWith(ValueProviderUtil.GetPrefixes(key));

                    // need to look up values lazily, as eagerly looking at the collection might trigger validation
                    _values[key] = new ValueProviderResultPlaceholder(key, validatedCollection, unvalidatedCollection, culture);
                }
            }
        }
        private Dictionary<string, ValueProviderResultPlaceholder> InitializeCollectionValues()
        {
            Dictionary<string, ValueProviderResultPlaceholder> tempValues =
                            new Dictionary<string, ValueProviderResultPlaceholder>(StringComparer.OrdinalIgnoreCase);

            // Need to read keys from the unvalidated collection, as M.W.I's granular request validation is a bit touchy
            // and validated entries at the time the key or value is looked at. For example, GetKey() will throw if the
            // value fails request validation, even though the value's not being looked at (M.W.I can't tell the difference).

            foreach (string key in _unvalidatedCollection)
            {
                if (key != null)
                {
                    string normalizedKey = key;
                    if (_jQueryToMvcRequestNormalizationRequired)
                    {
                        normalizedKey = NormalizeJQueryToMvc(key);
                    }

                    // need to look up values lazily, as eagerly looking at the collection might trigger validation
                    tempValues[normalizedKey] =
                        new ValueProviderResultPlaceholder(key, _collection, _unvalidatedCollection, _culture);
                }
            }

            return tempValues;
        }