diff --git a/src/Microsoft.AspNet.Http/IReadableStringCollection.cs b/src/Microsoft.AspNet.Http/IReadableStringCollection.cs
index 21a00450ea..8f18b618ba 100644
--- a/src/Microsoft.AspNet.Http/IReadableStringCollection.cs
+++ b/src/Microsoft.AspNet.Http/IReadableStringCollection.cs
@@ -19,7 +19,22 @@ namespace Microsoft.AspNet.Http
///
string this[string key] { get; }
- // Joined
+ ///
+ /// Gets the number of elements contained in the collection.
+ ///
+ int Count { get; }
+
+ ///
+ /// Gets a collection containing the keys.
+ ///
+ ICollection Keys { get; }
+
+ ///
+ /// Determines whether the collection contains an element with the specified key.
+ ///
+ ///
+ ///
+ bool ContainsKey(string key);
///
/// Get the associated value from the collection. Multiple values will be merged.
@@ -30,8 +45,6 @@ namespace Microsoft.AspNet.Http
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Re-evaluate later.")]
string Get(string key);
- // Joined
-
///
/// Get the associated values from the collection in their original format.
/// Returns null if the key is not present.
@@ -39,7 +52,5 @@ namespace Microsoft.AspNet.Http
///
///
IList GetValues(string key);
-
- // Raw
}
}
diff --git a/src/Microsoft.AspNet.PipelineCore/Collections/ReadableStringCollection.cs b/src/Microsoft.AspNet.PipelineCore/Collections/ReadableStringCollection.cs
index 84f95d7e0e..139d8d1c78 100644
--- a/src/Microsoft.AspNet.PipelineCore/Collections/ReadableStringCollection.cs
+++ b/src/Microsoft.AspNet.PipelineCore/Collections/ReadableStringCollection.cs
@@ -31,6 +31,23 @@ namespace Microsoft.AspNet.PipelineCore.Collections
private IDictionary Store { get; set; }
+ ///
+ /// Gets the number of elements contained in the collection.
+ ///
+ public int Count
+ {
+ get { return Store.Count; }
+ }
+
+ ///
+ /// Gets a collection containing the keys.
+ ///
+ public ICollection Keys
+ {
+ get { return Store.Keys; }
+ }
+
+
///
/// Get the associated value from the collection. Multiple values will be merged.
/// Returns null if the key is not present.
@@ -42,6 +59,16 @@ namespace Microsoft.AspNet.PipelineCore.Collections
get { return Get(key); }
}
+ ///
+ /// Determines whether the collection contains an element with the specified key.
+ ///
+ ///
+ ///
+ public bool ContainsKey(string key)
+ {
+ return Store.ContainsKey(key);
+ }
+
///
/// Get the associated value from the collection. Multiple values will be merged.
/// Returns null if the key is not present.
diff --git a/src/Microsoft.AspNet.PipelineCore/Collections/RequestCookiesCollection.cs b/src/Microsoft.AspNet.PipelineCore/Collections/RequestCookiesCollection.cs
index e562487fd1..5fd131d990 100644
--- a/src/Microsoft.AspNet.PipelineCore/Collections/RequestCookiesCollection.cs
+++ b/src/Microsoft.AspNet.PipelineCore/Collections/RequestCookiesCollection.cs
@@ -18,30 +18,55 @@ namespace Microsoft.AspNet.PipelineCore.Collections
_dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase);
}
- public IEnumerator> GetEnumerator()
- {
- foreach (var pair in _dictionary)
- {
- yield return new KeyValuePair(pair.Key, new[] { pair.Value });
- }
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
public string this[string key]
{
get { return Get(key); }
}
+ ///
+ /// Gets the number of elements contained in the collection.
+ ///
+ public int Count
+ {
+ get { return _dictionary.Count; }
+ }
+
+ ///
+ /// Gets a collection containing the keys.
+ ///
+ public ICollection Keys
+ {
+ get { return _dictionary.Keys; }
+ }
+
+ ///
+ /// Determines whether the collection contains an element with the specified key.
+ ///
+ ///
+ ///
+ public bool ContainsKey(string key)
+ {
+ return _dictionary.ContainsKey(key);
+ }
+
+ ///
+ /// Get the associated value from the collection. Multiple values will be merged.
+ /// Returns null if the key is not present.
+ ///
+ ///
+ ///
public string Get(string key)
{
string value;
return _dictionary.TryGetValue(key, out value) ? value : null;
}
+ ///
+ /// Get the associated values from the collection in their original format.
+ /// Returns null if the key is not present.
+ ///
+ ///
+ ///
public IList GetValues(string key)
{
string value;
@@ -56,6 +81,19 @@ namespace Microsoft.AspNet.PipelineCore.Collections
ParsingHelpers.ParseDelimited(cookiesHeader, SemicolonAndComma, AddCookieCallback, _dictionary);
}
+ public IEnumerator> GetEnumerator()
+ {
+ foreach (var pair in _dictionary)
+ {
+ yield return new KeyValuePair(pair.Key, new[] { pair.Value });
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+
private static readonly Action AddCookieCallback = (name, value, state) =>
{
var dictionary = (IDictionary)state;