diff options
author | Jo Shields <directhex@apebox.org> | 2014-02-19 22:12:43 +0000 |
---|---|---|
committer | Jo Shields <directhex@apebox.org> | 2014-02-19 22:12:43 +0000 |
commit | 9972bf87b4f27d9c8f358ef8414ac1ab957a2f0f (patch) | |
tree | 5bb230c1d698659115f918e243c1d4b0aa4c7f51 /mcs/class/System.Net.Http/System.Net.Http.Headers/StringWithQualityHeaderValue.cs | |
parent | d0a215f5626219ff7927f576588a777e5331c7be (diff) | |
download | mono-upstream/3.2.8+dfsg.tar.gz |
Imported Upstream version 3.2.8+dfsgupstream/3.2.8+dfsg
Diffstat (limited to 'mcs/class/System.Net.Http/System.Net.Http.Headers/StringWithQualityHeaderValue.cs')
-rw-r--r-- | mcs/class/System.Net.Http/System.Net.Http.Headers/StringWithQualityHeaderValue.cs | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/mcs/class/System.Net.Http/System.Net.Http.Headers/StringWithQualityHeaderValue.cs b/mcs/class/System.Net.Http/System.Net.Http.Headers/StringWithQualityHeaderValue.cs index 635ed00223..648d4222e3 100644 --- a/mcs/class/System.Net.Http/System.Net.Http.Headers/StringWithQualityHeaderValue.cs +++ b/mcs/class/System.Net.Http/System.Net.Http.Headers/StringWithQualityHeaderValue.cs @@ -27,6 +27,8 @@ // using System.Globalization; +using System.Collections.Generic; + namespace System.Net.Http.Headers { public class StringWithQualityHeaderValue : ICloneable @@ -82,10 +84,24 @@ namespace System.Net.Http.Headers public static bool TryParse (string input, out StringWithQualityHeaderValue parsedValue) { + var lexer = new Lexer (input); + Token token; + if (TryParseElement (lexer, out parsedValue, out token) && token == Token.Type.End) + return true; + parsedValue = null; + return false; + } - var lexer = new Lexer (input); - var t = lexer.Scan (); + internal static bool TryParse (string input, int minimalCount, out List<StringWithQualityHeaderValue> result) + { + return CollectionParser.TryParse (input, minimalCount, TryParseElement, out result); + } + + static bool TryParseElement (Lexer lexer, out StringWithQualityHeaderValue parsedValue, out Token t) + { + parsedValue = null; + t = lexer.Scan (); if (t != Token.Type.Token) return false; @@ -120,9 +136,6 @@ namespace System.Net.Http.Headers t = lexer.Scan (); } - if (t != Token.Type.End) - return false; - parsedValue = value; return true; } |