diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-08-27 13:34:55 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-27 13:34:55 -0400 |
| commit | f3ee129bd9e88e8768221ba176bc8356f9b240e3 (patch) | |
| tree | 72dc082f77629e8d70f764d175433b40ac4c02d0 /MediaBrowser.Model/Services/QueryParamCollection.cs | |
| parent | 4f8684a16b1102056bd2b527dcbd585b78dd8000 (diff) | |
| parent | fa6bec94b59cf850246c5d0757b9279d080643d7 (diff) | |
Merge pull request #2847 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Model/Services/QueryParamCollection.cs')
| -rw-r--r-- | MediaBrowser.Model/Services/QueryParamCollection.cs | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/MediaBrowser.Model/Services/QueryParamCollection.cs b/MediaBrowser.Model/Services/QueryParamCollection.cs index a3e00f587..e13e5feca 100644 --- a/MediaBrowser.Model/Services/QueryParamCollection.cs +++ b/MediaBrowser.Model/Services/QueryParamCollection.cs @@ -58,9 +58,7 @@ namespace MediaBrowser.Model.Services { if (string.IsNullOrWhiteSpace(value)) { - var stringComparison = GetStringComparison(); - - var parameters = this.Where(p => string.Equals(key, p.Name, stringComparison)).ToArray(); + var parameters = GetItems(key); foreach (var p in parameters) { @@ -85,14 +83,6 @@ namespace MediaBrowser.Model.Services } /// <summary> - /// True if the collection contains a query parameter with the given name. - /// </summary> - public bool ContainsKey(string name) - { - return this.Any(p => p.Name == name); - } - - /// <summary> /// Removes all parameters of the given name. /// </summary> /// <returns>The number of parameters that were removed</returns> @@ -106,16 +96,49 @@ namespace MediaBrowser.Model.Services { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)) - .Select(p => p.Value) - .FirstOrDefault(); + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + return pair.Value; + } + } + + return null; + } + + public virtual List<NameValuePair> GetItems(string name) + { + var stringComparison = GetStringComparison(); + + var list = new List<NameValuePair>(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair); + } + } + + return list; } - public virtual string[] GetValues(string name) + public virtual List<string> GetValues(string name) { var stringComparison = GetStringComparison(); - return this.Where(p => string.Equals(p.Name, name, stringComparison)).Select(p => p.Value).ToArray(); + var list = new List<string>(); + + foreach (var pair in this) + { + if (string.Equals(pair.Name, name, stringComparison)) + { + list.Add(pair.Value); + } + } + + return list; } public Dictionary<string, string> ToDictionary() @@ -134,7 +157,17 @@ namespace MediaBrowser.Model.Services public IEnumerable<string> Keys { - get { return this.Select(i => i.Name); } + get + { + var keys = new string[this.Count]; + + for (var i = 0; i < keys.Length; i++) + { + keys[i] = this[i].Name; + } + + return keys; + } } /// <summary> |
