/// <exception cref="InvalidOperationException"><c>InvalidOperationException</c>.</exception> private static void Test(string uriString) { var reader = new StringReader(); reader.Assign(uriString); SipUri uri = Parse(reader); if (uri == null) { throw new InvalidOperationException("Failed to parse: " + uriString); } Assert.Equal(uriString, uri.ToString()); }
/// <summary> /// Parse a header. /// </summary> /// <param name="name">Name of header</param> /// <param name="value">Header value</param> /// <returns>Header.</returns> /// <exception cref="FormatException">Value is not a well formatted header value.</exception> public IHeader Parse(string name, string value) { IHeaderParser parser; if (!_parsers.TryGetValue(name, out parser)) { parser = _stringParser; } StringReader reader = _readers.Dequeue(); reader.Assign(value); try { return(parser.Parse(name, reader)); } finally { _readers.Enqueue(reader); } }
public IHeader Parse(string name, string value) { _logger.Trace("Parsing [" + name + "] " + value); IHeaderParser parser = GetParser(name); StringReader reader = _readers.Dequeue(); try { if (parser == null) { return(CreateDefaultHeader(name, value)); } reader.Assign(value); return(parser.Parse(name, reader)); } finally { _readers.Enqueue(reader); } }