RouteValueDictionary.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Routing / RouteValueDictionary.cs / 1305376 / RouteValueDictionary.cs

                            namespace System.Web.Routing { 
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Runtime.CompilerServices; 

    [TypeForwardedFrom("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")] 
    public class RouteValueDictionary : IDictionary { 
        private Dictionary _dictionary;
 
        public RouteValueDictionary() {
            _dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
        }
 
        public RouteValueDictionary(object values) {
            _dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); 
 
            AddValues(values);
        } 

        public RouteValueDictionary(IDictionary dictionary) {
            _dictionary = new Dictionary(dictionary, StringComparer.OrdinalIgnoreCase);
        } 

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public int Count { 
            get {
                return _dictionary.Count; 
            }
        }

        public Dictionary.KeyCollection Keys { 
            get {
                return _dictionary.Keys; 
            } 
        }
 
        public Dictionary.ValueCollection Values {
            get {
                return _dictionary.Values;
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public object this[string key] {
            get { 
                object value;
                TryGetValue(key, out value);
                return value;
            } 
            set {
                _dictionary[key] = value; 
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public void Add(string key, object value) {
            _dictionary.Add(key, value);
        } 

        private void AddValues(object values) { 
            if (values != null) { 
                PropertyDescriptorCollection props = TypeDescriptor.GetProperties(values);
                foreach (PropertyDescriptor prop in props) { 
                    object val = prop.GetValue(values);
                    Add(prop.Name, val);
                }
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public void Clear() {
            _dictionary.Clear(); 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public bool ContainsKey(string key) { 
            return _dictionary.ContainsKey(key);
        } 
 
        public bool ContainsValue(object value) {
            return _dictionary.ContainsValue(value); 
        }

        public Dictionary.Enumerator GetEnumerator() {
            return _dictionary.GetEnumerator(); 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public bool Remove(string key) {
            return _dictionary.Remove(key); 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public bool TryGetValue(string key, out object value) { 
            return _dictionary.TryGetValue(key, out value);
        } 
 
        #region IDictionary Members
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        ICollection IDictionary.Keys {
            get {
                return _dictionary.Keys;
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        ICollection IDictionary.Values {
            get { 
                return _dictionary.Values;
            }
        }
        #endregion 

        #region ICollection> Members 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        void ICollection>.Add(KeyValuePair item) {
            ((ICollection>)_dictionary).Add(item); 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        bool ICollection>.Contains(KeyValuePair item) { 
            return ((ICollection>)_dictionary).Contains(item);
        } 
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) { 
            ((ICollection>)_dictionary).CopyTo(array, arrayIndex);
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        bool ICollection>.IsReadOnly {
            get { 
                return ((ICollection>)_dictionary).IsReadOnly; 
            }
        } 

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        bool ICollection>.Remove(KeyValuePair item) {
            return ((ICollection>)_dictionary).Remove(item); 
        }
        #endregion 
 
        #region IEnumerable> Members
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        IEnumerator> IEnumerable>.GetEnumerator() {
            return GetEnumerator();
        }
        #endregion 

        #region IEnumerable Members 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        IEnumerator IEnumerable.GetEnumerator() {
            return GetEnumerator(); 
        }
        #endregion
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
´╗┐namespace System.Web.Routing { 
    using System.Collections;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Runtime.CompilerServices; 

    [TypeForwardedFrom("System.Web.Routing, Version=3.5.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35")] 
    public class RouteValueDictionary : IDictionary { 
        private Dictionary _dictionary;
 
        public RouteValueDictionary() {
            _dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
        }
 
        public RouteValueDictionary(object values) {
            _dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); 
 
            AddValues(values);
        } 

        public RouteValueDictionary(IDictionary dictionary) {
            _dictionary = new Dictionary(dictionary, StringComparer.OrdinalIgnoreCase);
        } 

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public int Count { 
            get {
                return _dictionary.Count; 
            }
        }

        public Dictionary.KeyCollection Keys { 
            get {
                return _dictionary.Keys; 
            } 
        }
 
        public Dictionary.ValueCollection Values {
            get {
                return _dictionary.Values;
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public object this[string key] {
            get { 
                object value;
                TryGetValue(key, out value);
                return value;
            } 
            set {
                _dictionary[key] = value; 
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public void Add(string key, object value) {
            _dictionary.Add(key, value);
        } 

        private void AddValues(object values) { 
            if (values != null) { 
                PropertyDescriptorCollection props = TypeDescriptor.GetProperties(values);
                foreach (PropertyDescriptor prop in props) { 
                    object val = prop.GetValue(values);
                    Add(prop.Name, val);
                }
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public void Clear() {
            _dictionary.Clear(); 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public bool ContainsKey(string key) { 
            return _dictionary.ContainsKey(key);
        } 
 
        public bool ContainsValue(object value) {
            return _dictionary.ContainsValue(value); 
        }

        public Dictionary.Enumerator GetEnumerator() {
            return _dictionary.GetEnumerator(); 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        public bool Remove(string key) {
            return _dictionary.Remove(key); 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        public bool TryGetValue(string key, out object value) { 
            return _dictionary.TryGetValue(key, out value);
        } 
 
        #region IDictionary Members
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        ICollection IDictionary.Keys {
            get {
                return _dictionary.Keys;
            } 
        }
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        ICollection IDictionary.Values {
            get { 
                return _dictionary.Values;
            }
        }
        #endregion 

        #region ICollection> Members 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        void ICollection>.Add(KeyValuePair item) {
            ((ICollection>)_dictionary).Add(item); 
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        bool ICollection>.Contains(KeyValuePair item) { 
            return ((ICollection>)_dictionary).Contains(item);
        } 
 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) { 
            ((ICollection>)_dictionary).CopyTo(array, arrayIndex);
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        bool ICollection>.IsReadOnly {
            get { 
                return ((ICollection>)_dictionary).IsReadOnly; 
            }
        } 

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
        bool ICollection>.Remove(KeyValuePair item) {
            return ((ICollection>)_dictionary).Remove(item); 
        }
        #endregion 
 
        #region IEnumerable> Members
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        IEnumerator> IEnumerable>.GetEnumerator() {
            return GetEnumerator();
        }
        #endregion 

        #region IEnumerable Members 
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")] 
        IEnumerator IEnumerable.GetEnumerator() {
            return GetEnumerator(); 
        }
        #endregion
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK