本文整理汇总了C#中StringReader.QuotedReadToDelimiter方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.QuotedReadToDelimiter方法的具体用法?C# StringReader.QuotedReadToDelimiter怎么用?C# StringReader.QuotedReadToDelimiter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringReader
的用法示例。
在下文中一共展示了StringReader.QuotedReadToDelimiter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parses media from "a" SDP message field.
/// </summary>
/// <param name="aValue">"a" SDP message field.</param>
/// <returns></returns>
public static SDP_Attribute Parse(string aValue)
{
// a=<attribute>
// a=<attribute>:<value>
// Remove a=
StringReader r = new StringReader(aValue);
r.QuotedReadToDelimiter('=');
//--- <attribute> ------------------------------------------------------------
string name = "";
string word = r.QuotedReadToDelimiter(':');
if(word == null){
throw new Exception("SDP message \"a\" field <attribute> name is missing !");
}
name = word;
//--- <value> ----------------------------------------------------------------
string value ="";
word = r.ReadToEnd();
if(word != null){
value = word;
}
return new SDP_Attribute(name,value);
}
示例2: Parse
/// <summary>
/// Parses media from "c" SDP message field.
/// </summary>
/// <param name="cValue">"m" SDP message field.</param>
/// <returns></returns>
public static SDP_Connection Parse(string cValue)
{
// c=<nettype> <addrtype> <connection-address>
string netType = "";
string addrType = "";
string connectionAddress = "";
// Remove c=
StringReader r = new StringReader(cValue);
r.QuotedReadToDelimiter('=');
//--- <nettype> ------------------------------------------------------------
string word = r.ReadWord();
if(word == null){
throw new Exception("SDP message \"c\" field <nettype> value is missing !");
}
netType = word;
//--- <addrtype> -----------------------------------------------------------
word = r.ReadWord();
if(word == null){
throw new Exception("SDP message \"c\" field <addrtype> value is missing !");
}
addrType = word;
//--- <connection-address> -------------------------------------------------
word = r.ReadWord();
if(word == null){
throw new Exception("SDP message \"c\" field <connection-address> value is missing !");
}
connectionAddress = word;
return new SDP_Connection(netType,addrType,connectionAddress);
}
示例3: Parse
/// <summary>
/// Returns parsed IMAP SEARCH <b>UID (sequence set)</b> key.
/// </summary>
/// <param name="r">String reader.</param>
/// <returns>Returns parsed IMAP SEARCH <b>UID (sequence set)</b> key.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
/// <exception cref="ParseException">Is raised when parsing fails.</exception>
internal static IMAP_Search_Key_Uid Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
string word = r.ReadWord();
if(!string.Equals(word,"UID",StringComparison.InvariantCultureIgnoreCase)){
throw new ParseException("Parse error: Not a SEARCH 'UID' key.");
}
r.ReadToFirstChar();
string value = r.QuotedReadToDelimiter(' ');
if(value == null){
throw new ParseException("Parse error: Invalid 'UID' value.");
}
IMAP_SequenceSet seqSet = new IMAP_SequenceSet();
try{
seqSet.Parse(value);
}
catch{
throw new ParseException("Parse error: Invalid 'UID' value.");
}
return new IMAP_Search_Key_Uid(seqSet);
}
示例4: Parse
/// <summary>
/// Parses media from "t" SDP message field.
/// </summary>
/// <param name="tValue">"t" SDP message field.</param>
/// <returns></returns>
public static SDP_Time Parse(string tValue)
{
// t=<start-time> <stop-time>
SDP_Time time = new SDP_Time();
// Remove t=
StringReader r = new StringReader(tValue);
r.QuotedReadToDelimiter('=');
//--- <start-time> ------------------------------------------------------------
string word = r.ReadWord();
if(word == null){
throw new Exception("SDP message \"t\" field <start-time> value is missing !");
}
time.m_StartTime = Convert.ToInt64(word);
//--- <stop-time> -------------------------------------------------------------
word = r.ReadWord();
if(word == null){
throw new Exception("SDP message \"t\" field <stop-time> value is missing !");
}
time.m_StopTime = Convert.ToInt64(word);
return time;
}
示例5: ParseParameters
/// <summary>
/// Parses parameters from specified reader. Reader position must be where parameters begin.
/// </summary>
/// <param name="reader">Reader from where to read parameters.</param>
/// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
protected void ParseParameters(StringReader reader)
{
// Remove all old parameters.
m_pParameters.Clear();
// Parse parameters
while(reader.Available > 0){
reader.ReadToFirstChar();
// We have parameter
if(reader.SourceString.StartsWith(";")){
reader.ReadSpecifiedLength(1);
string paramString = reader.QuotedReadToDelimiter(new char[]{';',','},false);
if(paramString != ""){
string[] name_value = paramString.Split(new char[]{'='},2);
if(name_value.Length == 2){
this.Parameters.Add(name_value[0],TextUtils.UnQuoteString(name_value[1]));
}
else{
this.Parameters.Add(name_value[0],null);
}
}
}
// Next value
else if(reader.SourceString.StartsWith(",")){
break;
}
// Unknown data
else{
throw new SIP_ParseException("Unexpected value '" + reader.SourceString + "' !");
}
}
}
示例6: Parse
/// <summary>
/// Returns parsed IMAP SEARCH <b>sequence-set</b> key.
/// </summary>
/// <param name="r">String reader.</param>
/// <returns>Returns parsed IMAP SEARCH <b>sequence-set</b> key.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
/// <exception cref="ParseException">Is raised when parsing fails.</exception>
internal static IMAP_Search_Key_SeqSet Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
r.ReadToFirstChar();
string value = r.QuotedReadToDelimiter(' ');
if(value == null){
throw new ParseException("Parse error: Invalid 'sequence-set' value.");
}
IMAP_SequenceSet seqSet = new IMAP_SequenceSet();
try{
seqSet.Parse(value);
}
catch{
throw new ParseException("Parse error: Invalid 'sequence-set' value.");
}
return new IMAP_Search_Key_SeqSet(seqSet);
}
示例7: Parse
/// <summary>
/// Parses "alert-param" from specified reader.
/// </summary>
/// <param name="reader">Reader from where to parse.</param>
/// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
/// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
public override void Parse(StringReader reader)
{
/*
alert-param = LAQUOT absoluteURI RAQUOT *( SEMI generic-param )
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
// Parse uri
// Read to LAQUOT
reader.QuotedReadToDelimiter('<');
if(!reader.StartsWith("<")){
throw new SIP_ParseException("Invalid Alert-Info value, Uri not between <> !");
}
m_Uri = reader.ReadParenthesized();
// Parse parameters
ParseParameters(reader);
}
示例8: Parse
/// <summary>
/// Parses "error-uri" from specified reader.
/// </summary>
/// <param name="reader">Reader from where to parse.</param>
/// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
/// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
public override void Parse(StringReader reader)
{
/*
Error-Info = "Error-Info" HCOLON error-uri *(COMMA error-uri)
error-uri = LAQUOT absoluteURI RAQUOT *( SEMI generic-param )
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
// Parse uri
// Read to LAQUOT
reader.QuotedReadToDelimiter('<');
if(!reader.StartsWith("<")){
throw new SIP_ParseException("Invalid 'error-uri' value, Uri not between <> !");
}
// Parse parameters
ParseParameters(reader);
}
示例9: Parse
/// <summary>
/// Parses "Authentication-Info" from specified reader.
/// </summary>
/// <param name="reader">Reader what contains Authentication-Info value.</param>
/// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
/// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
public override void Parse(StringReader reader)
{
/*
Authentication-Info = "Authentication-Info" HCOLON ainfo *(COMMA ainfo)
ainfo = nextnonce / message-qop / response-auth / cnonce / nonce-count
nextnonce = "nextnonce" EQUAL nonce-value
response-auth = "rspauth" EQUAL response-digest
response-digest = LDQUOT *LHEX RDQUOT
nc-value = 8LHEX
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
while(reader.Available > 0){
string word = reader.QuotedReadToDelimiter(',');
if(word != null && word.Length > 0){
string[] name_value = word.Split(new char[]{'='},2);
if(name_value[0].ToLower() == "nextnonce"){
this.NextNonce = name_value[1];
}
else if(name_value[0].ToLower() == "qop"){
this.Qop = name_value[1];
}
else if(name_value[0].ToLower() == "rspauth"){
this.ResponseAuth = name_value[1];
}
else if(name_value[0].ToLower() == "cnonce"){
this.CNonce = name_value[1];
}
else if(name_value[0].ToLower() == "nc"){
this.NonceCount = Convert.ToInt32(name_value[1]);
}
else{
throw new SIP_ParseException("Invalid Authentication-Info value !");
}
}
}
}
示例10: Parse
/// <summary>
/// Parses "info" from specified reader.
/// </summary>
/// <param name="reader">Reader from where to parse.</param>
/// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
/// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
public override void Parse(StringReader reader)
{
/*
Call-Info = "Call-Info" HCOLON info *(COMMA info)
info = LAQUOT absoluteURI RAQUOT *( SEMI info-param)
info-param = ( "purpose" EQUAL ( "icon" / "info" / "card" / token ) ) / generic-param
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
// Parse uri
// Read to LAQUOT
reader.QuotedReadToDelimiter('<');
if(!reader.StartsWith("<")){
throw new SIP_ParseException("Invalid Alert-Info value, Uri not between <> !");
}
// Parse parameters
ParseParameters(reader);
}
示例11: Parse
/// <summary>
/// Parses "via-parm" from specified reader.
/// </summary>
/// <param name="reader">Reader from where to parse.</param>
/// <exception cref="ArgumentNullException">Raised when <b>reader</b> is null.</exception>
/// <exception cref="SIP_ParseException">Raised when invalid SIP message.</exception>
public override void Parse(StringReader reader)
{
/*
via-parm = sent-protocol LWS sent-by *( SEMI via-params )
via-params = via-ttl / via-maddr / via-received / via-branch / via-extension
via-ttl = "ttl" EQUAL ttl
via-maddr = "maddr" EQUAL host
via-received = "received" EQUAL (IPv4address / IPv6address)
via-branch = "branch" EQUAL token
via-extension = generic-param
sent-protocol = protocol-name SLASH protocol-version
SLASH transport
protocol-name = "SIP" / token
protocol-version = token
transport = "UDP" / "TCP" / "TLS" / "SCTP" / other-transport
sent-by = host [ COLON port ]
ttl = 1*3DIGIT ; 0 to 255
Via extentions:
// RFC 3486
via-compression = "comp" EQUAL ("sigcomp" / other-compression)
// RFC 3581
response-port = "rport" [EQUAL 1*DIGIT]
Examples:
Via: SIP/2.0/UDP 127.0.0.1:58716;branch=z9hG4bK-d87543-4d7e71216b27df6e-1--d87543-
// Specifically, LWS on either side of the ":" or "/" is allowed.
Via: SIP / 2.0 / UDP 127.0.0.1:58716;branch=z9hG4bK-d87543-4d7e71216b27df6e-1--d87543-
*/
if (reader == null)
{
throw new ArgumentNullException("reader");
}
// protocol-name
string word = reader.QuotedReadToDelimiter('/');
if (word == null)
{
throw new SIP_ParseException("Via header field protocol-name is missing !");
}
ProtocolName = word.Trim();
// protocol-version
word = reader.QuotedReadToDelimiter('/');
if (word == null)
{
throw new SIP_ParseException("Via header field protocol-version is missing !");
}
ProtocolVersion = word.Trim();
// transport
word = reader.ReadWord();
if (word == null)
{
throw new SIP_ParseException("Via header field transport is missing !");
}
ProtocolTransport = word.Trim();
// sent-by
word = reader.QuotedReadToDelimiter(new[] {';', ','}, false);
if (word == null)
{
throw new SIP_ParseException("Via header field sent-by is missing !");
}
SentBy = HostEndPoint.Parse(word.Trim());
// Parse parameters
ParseParameters(reader);
}
示例12: Parse
/// <summary>
/// Parses address-list from string.
/// </summary>
/// <param name="addressList">Address list string.</param>
/// <returns></returns>
public void Parse(string addressList)
{
addressList = addressList.Trim();
StringReader reader = new StringReader(addressList);
while(reader.SourceString.Length > 0){
// See if mailbox or group. If ',' is before ':', then mailbox
// Example: [email protected], group:[email protected];
int commaIndex = TextUtils.QuotedIndexOf(reader.SourceString,',');
int colonIndex = TextUtils.QuotedIndexOf(reader.SourceString,':');
// Mailbox
if(colonIndex == -1 || (commaIndex < colonIndex && commaIndex != -1)){
// FIX: why quotes missing
//System.Windows.Forms.MessageBox.Show(reader.SourceString + "#" + reader.OriginalString);
// Read to ',' or to end if last element
MailboxAddress address = MailboxAddress.Parse(reader.QuotedReadToDelimiter(','));
m_pAddresses.Add(address);
address.Owner = this;
}
// Group
else{
// Read to ';', this is end of group
GroupAddress address = GroupAddress.Parse(reader.QuotedReadToDelimiter(';'));
m_pAddresses.Add(address);
address.Owner = this;
// If there are next items, remove first comma because it's part of group address
if(reader.SourceString.Length > 0){
reader.QuotedReadToDelimiter(',');
}
}
}
OnCollectionChanged();
}
示例13: Parse
/// <summary>
/// Parses one search key from current position. Returns null if there isn't any search key left.
/// </summary>
/// <param name="reader"></param>
public static SearchKey Parse(StringReader reader)
{
string searchKeyName = "";
object searchKeyValue = null;
//Remove spaces from string start
reader.ReadToFirstChar();
// Search keyname is always 1 word
string word = reader.ReadWord();
if (word == null)
{
return null;
}
word = word.ToUpper().Trim();
//Remove spaces from string start
reader.ReadToFirstChar();
#region ALL
// ALL
// All messages in the mailbox; the default initial key for ANDing.
if (word == "ALL")
{
searchKeyName = "ALL";
}
#endregion
#region ANSWERED
// ANSWERED
// Messages with the \Answered flag set.
else if (word == "ANSWERED")
{
// We internally use KEYWORD ANSWERED
searchKeyName = "KEYWORD";
searchKeyValue = "ANSWERED";
}
#endregion
#region BCC
// BCC <string>
// Messages that contain the specified string in the envelope structure's BCC field.
else if (word == "BCC")
{
// We internally use HEADER "BCC:" "value"
searchKeyName = "HEADER";
// Read <string>
string val = ReadString(reader);
if (val != null)
{
searchKeyValue = new[] {"BCC:", TextUtils.UnQuoteString(val)};
}
else
{
throw new Exception("BCC <string> value is missing !");
}
}
#endregion
#region BEFORE
// BEFORE <date>
// Messages whose internal date (disregarding time and timezone) is earlier than the specified date.
else if (word == "BEFORE")
{
searchKeyName = "BEFORE";
// Read <date>
string val = reader.QuotedReadToDelimiter(' ');
if (val != null)
{
// Parse date
try
{
searchKeyValue = IMAP_Utils.ParseDate(TextUtils.UnQuoteString(val));
}
// Invalid date
catch
{
throw new Exception("Invalid BEFORE <date> value '" + val +
"', valid date syntax: {dd-MMM-yyyy} !");
}
}
else
{
throw new Exception("BEFORE <date> value is missing !");
}
}
//.........这里部分代码省略.........
示例14: ReadString
/// <summary>
/// Reads search-key <string> value.
/// </summary>
/// <param name="reader"></param>
/// <returns></returns>
private static string ReadString(StringReader reader)
{
//Remove spaces from string start
reader.ReadToFirstChar();
// We must support:
// word
// "text"
// {string_length}data(string_length)
// {string_length}data(string_length)
if (reader.StartsWith("{"))
{
// Remove {
reader.ReadSpecifiedLength("{".Length);
int dataLength = Convert.ToInt32(reader.QuotedReadToDelimiter('}'));
return reader.ReadSpecifiedLength(dataLength);
}
return TextUtils.UnQuoteString(reader.QuotedReadToDelimiter(' '));
}
示例15: Parse
/// <summary>
/// Parses media from "c" SDP message field.
/// </summary>
/// <param name="cValue">"m" SDP message field.</param>
/// <returns></returns>
public static SDP_ConnectionData Parse(string cValue)
{
// c=<nettype> <addrtype> <connection-address>
SDP_ConnectionData connectionInfo = new SDP_ConnectionData();
// Remove c=
StringReader r = new StringReader(cValue);
r.QuotedReadToDelimiter('=');
//--- <nettype> ------------------------------------------------------------
string word = r.ReadWord();
if (word == null)
{
throw new Exception("SDP message \"c\" field <nettype> value is missing !");
}
connectionInfo.m_NetType = word;
//--- <addrtype> -----------------------------------------------------------
word = r.ReadWord();
if (word == null)
{
throw new Exception("SDP message \"c\" field <addrtype> value is missing !");
}
connectionInfo.m_AddressType = word;
//--- <connection-address> -------------------------------------------------
word = r.ReadWord();
if (word == null)
{
throw new Exception("SDP message \"c\" field <connection-address> value is missing !");
}
connectionInfo.m_Address = word;
return connectionInfo;
}