1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
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<string, object> {
private Dictionary<string, object> _dictionary;
public RouteValueDictionary() {
_dictionary = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
}
public RouteValueDictionary(object values) {
_dictionary = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
AddValues(values);
}
public RouteValueDictionary(IDictionary<string, object> dictionary) {
_dictionary = new Dictionary<string, object>(dictionary, StringComparer.OrdinalIgnoreCase);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
public int Count {
get {
return _dictionary.Count;
}
}
public Dictionary<string, object>.KeyCollection Keys {
get {
return _dictionary.Keys;
}
}
public Dictionary<string, object>.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<string, object>.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<string,object> Members
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
ICollection<string> IDictionary<string, object>.Keys {
get {
return _dictionary.Keys;
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
ICollection<object> IDictionary<string, object>.Values {
get {
return _dictionary.Values;
}
}
#endregion
#region ICollection<KeyValuePair<string,object>> Members
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item) {
((ICollection<KeyValuePair<string, object>>)_dictionary).Add(item);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
bool ICollection<KeyValuePair<string, object>>.Contains(KeyValuePair<string, object> item) {
return ((ICollection<KeyValuePair<string, object>>)_dictionary).Contains(item);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex) {
((ICollection<KeyValuePair<string, object>>)_dictionary).CopyTo(array, arrayIndex);
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
bool ICollection<KeyValuePair<string, object>>.IsReadOnly {
get {
return ((ICollection<KeyValuePair<string, object>>)_dictionary).IsReadOnly;
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item) {
return ((ICollection<KeyValuePair<string, object>>)_dictionary).Remove(item);
}
#endregion
#region IEnumerable<KeyValuePair<string,object>> Members
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator() {
return GetEnumerator();
}
#endregion
#region IEnumerable Members
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
IEnumerator IEnumerable.GetEnumerator() {
return GetEnumerator();
}
#endregion
}
}
|