/// <summary> /// Parse a message value. /// </summary> /// <param name="name">Name of header being parsed.</param> /// <param name="reader">Reader containing the string that should be parsed.</param> /// <returns>Newly created header.</returns> /// <exception cref="ParseException">Header value is malformed.</exception> public IHeader Parse(string name, ITextReader reader) { ViaEntry entry = ParseEntry(reader); if (reader.Current != ',') { return new Via { entry } } ; var via = new Via { entry }; while (reader.Current == ',') { reader.ConsumeWhiteSpaces(','); entry = ParseEntry(reader); via.Add(entry); } return(via); } #endregion }
/// <summary> /// Assign a header /// </summary> /// <param name="name">Long name, in lower case.</param> /// <param name="header">Header to assign</param> internal virtual void Assign(string name, IHeader header) { switch (name) { case "to": To = ((ContactHeader)header).FirstContact; break; case "from": From = ((ContactHeader)header).FirstContact; break; case "cseq": CSeq = (CSeq)header; break; case "via": var via = (Via)header; if (Via != null && Via.Items.Count > 0) { foreach (ViaEntry entry in via) { Via.Add(entry); } } else { Via = via; } break; } Headers.Add(name.ToLower(), header); }
/// <summary> /// Parse a message value. /// </summary> /// <param name="name">Name of header being parsed.</param> /// <param name="reader">Reader containing the string that should be parsed.</param> /// <returns>Newly created header.</returns> /// <exception cref="ParseException">Header value is malformed.</exception> public IHeader Parse(string name, ITextReader reader) { ViaEntry entry = ParseEntry(reader); if (reader.Current != ',') return new Via {entry}; var via = new Via {entry}; while (reader.Current == ',') { reader.ConsumeWhiteSpaces(','); entry = ParseEntry(reader); via.Add(entry); } return via; }