diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-11-08 14:55:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-08 14:55:32 -0500 |
| commit | 82c46a84e4ce7419a92e6c5674de92d69b6ae11a (patch) | |
| tree | c7263a8e6aaf43680a2de2d3ae00be15be6cd1ad /MediaBrowser.Model/Services/QueryParamCollection.cs | |
| parent | a86e9fa73dd159db89efd2ae3e206f45a53c784c (diff) | |
| parent | e8c70da2b6044243d8352af8358dd701afe570e5 (diff) | |
Merge pull request #2277 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Model/Services/QueryParamCollection.cs')
| -rw-r--r-- | MediaBrowser.Model/Services/QueryParamCollection.cs | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/MediaBrowser.Model/Services/QueryParamCollection.cs b/MediaBrowser.Model/Services/QueryParamCollection.cs index 1ab3f0bfb..dfea62821 100644 --- a/MediaBrowser.Model/Services/QueryParamCollection.cs +++ b/MediaBrowser.Model/Services/QueryParamCollection.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Model.Services { public QueryParamCollection() { - + } public QueryParamCollection(IDictionary<string, string> headers) @@ -30,15 +30,30 @@ namespace MediaBrowser.Model.Services return StringComparer.OrdinalIgnoreCase; } + public string GetKey(int index) + { + return this[index].Name; + } + + public string Get(int index) + { + return this[index].Value; + } + + public virtual string[] GetValues(int index) + { + return new[] { Get(index) }; + } + /// <summary> /// Adds a new query parameter. /// </summary> - public void Add(string key, string value) + public virtual void Add(string key, string value) { Add(new NameValuePair(key, value)); } - public void Set(string key, string value) + public virtual void Set(string key, string value) { if (string.IsNullOrWhiteSpace(value)) { @@ -81,17 +96,21 @@ namespace MediaBrowser.Model.Services /// </summary> /// <returns>The number of parameters that were removed</returns> /// <exception cref="ArgumentNullException"><paramref name="name" /> is null.</exception> - public int Remove(string name) + public virtual int Remove(string name) { return RemoveAll(p => p.Name == name); } public string Get(string name) { - return GetValues(name).FirstOrDefault(); + var stringComparison = GetStringComparison(); + + return this.Where(p => string.Equals(p.Name, name, stringComparison)) + .Select(p => p.Value) + .FirstOrDefault(); } - public string[] GetValues(string name) + public virtual string[] GetValues(string name) { var stringComparison = GetStringComparison(); |
