本文整理汇总了C#中StringReader.ReadToFirstChar方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.ReadToFirstChar方法的具体用法?C# StringReader.ReadToFirstChar怎么用?C# StringReader.ReadToFirstChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringReader
的用法示例。
在下文中一共展示了StringReader.ReadToFirstChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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 + "' !");
}
}
}
示例3: Parse
/// <summary>
/// Parses "accept-range" 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)
{
/*
accept-range = media-range [ accept-params ]
media-range = ("*//*" / (m-type SLASH "*") / (m-type SLASH m-subtype)) *(SEMI m-parameter)
accept-params = SEMI "q" EQUAL qvalue *(SEMI generic-param)
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
// Parse m-type
string word = reader.ReadWord();
if(word == null){
throw new SIP_ParseException("Invalid 'accept-range' value, m-type is missing !");
}
this.MediaType = word;
// Parse media and accept parameters !!! thats confusing part, RFC invalid.
bool media_accept = true;
while(reader.Available > 0){
reader.ReadToFirstChar();
// We have 'next' value, so we are done here.
if(reader.SourceString.StartsWith(",")){
break;
}
// We have parameter
else if(reader.SourceString.StartsWith(";")){
reader.ReadSpecifiedLength(1);
string paramString = reader.QuotedReadToDelimiter(new char[]{';',','},false);
if(paramString != ""){
string[] name_value = paramString.Split(new char[]{'='},2);
string name = name_value[0].Trim();
string value = "";
if(name_value.Length == 2){
value = name_value[1];
}
// If q, then accept parameters begin
if(name.ToLower() == "q"){
media_accept = false;
}
if(media_accept){
this.MediaParameters.Add(name,value);
}
else{
this.Parameters.Add(name,value);
}
}
}
// Unknown data
else{
throw new SIP_ParseException("SIP_t_AcceptRange unexpected prarameter value !");
}
}
}
示例4: Parse
/// <summary>
/// Parses IMAP optional response from reader.
/// </summary>
/// <param name="r">Optional response reader.</param>
/// <returns>Returns parsed optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public static IMAP_t_orc Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
r.ReadToFirstChar();
if(r.StartsWith("[ALERT",false)){
return IMAP_t_orc_Alert.Parse(r);
}
else if(r.StartsWith("[BADCHARSET",false)){
return IMAP_t_orc_BadCharset.Parse(r);
}
else if(r.StartsWith("[CAPABILITY",false)){
return IMAP_t_orc_Capability.Parse(r);
}
else if(r.StartsWith("[PARSE",false)){
return IMAP_t_orc_Parse.Parse(r);
}
else if(r.StartsWith("[PERMANENTFLAGS",false)){
return IMAP_t_orc_PermanentFlags.Parse(r);
}
else if(r.StartsWith("[READ-ONLY",false)){
return IMAP_t_orc_ReadOnly.Parse(r);
}
else if(r.StartsWith("[READ-WRITE",false)){
return IMAP_t_orc_ReadWrite.Parse(r);
}
else if(r.StartsWith("[TRYCREATE",false)){
return IMAP_t_orc_TryCreate.Parse(r);
}
else if(r.StartsWith("[UIDNEXT",false)){
return IMAP_t_orc_UidNext.Parse(r);
}
else if(r.StartsWith("[UIDVALIDITY",false)){
return IMAP_t_orc_UidValidity.Parse(r);
}
else if(r.StartsWith("[UNSEEN",false)){
return IMAP_t_orc_Unseen.Parse(r);
}
//---------------------
else if(r.StartsWith("[APPENDUID",false)){
return IMAP_t_orc_AppendUid.Parse(r);
}
else if(r.StartsWith("[COPYUID",false)){
return IMAP_t_orc_CopyUid.Parse(r);
}
else{
return IMAP_t_orc_Unknown.Parse(r);
}
}
示例5: Parse
/// <summary>
/// Parses IMAP FETCH BODYSTRUCTURE from reader.
/// </summary>
/// <param name="r">Fetch reader.</param>
/// <returns>Returns parsed bodystructure.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public static IMAP_t_Fetch_r_i_BodyStructure Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
IMAP_t_Fetch_r_i_BodyStructure retVal = new IMAP_t_Fetch_r_i_BodyStructure();
r.ReadToFirstChar();
// We have multipart message
if(r.StartsWith("(")){
retVal.m_pMessage = IMAP_t_Fetch_r_i_BodyStructure_e_Multipart.Parse(r);
}
// We have single-part message.
else{
retVal.m_pMessage = IMAP_t_Fetch_r_i_BodyStructure_e_SinglePart.Parse(r);
}
return retVal;
}
示例6: Parse
/// <summary>
/// Parses namespace info from IMAP NAMESPACE response string.
/// </summary>
/// <param name="namespaceString">IMAP NAMESPACE response string.</param>
/// <returns></returns>
internal static IMAP_NamespacesInfo Parse(string namespaceString)
{
StringReader r = new StringReader(namespaceString);
// Skip NAMESPACE
r.ReadWord();
IMAP_Namespace[] personalNamespaces = null;
IMAP_Namespace[] otherUsersNamespaces = null;
IMAP_Namespace[] sharedNamespaces = null;
// Personal namespace
r.ReadToFirstChar();
if(r.StartsWith("(")){
personalNamespaces = ParseNamespaces(r.ReadParenthesized());
}
// NIL, skip it.
else{
r.ReadWord();
}
// Users Shared namespace
r.ReadToFirstChar();
if(r.StartsWith("(")){
otherUsersNamespaces = ParseNamespaces(r.ReadParenthesized());
}
// NIL, skip it.
else{
r.ReadWord();
}
// Shared namespace
r.ReadToFirstChar();
if(r.StartsWith("(")){
sharedNamespaces = ParseNamespaces(r.ReadParenthesized());
}
// NIL, skip it.
else{
r.ReadWord();
}
return new IMAP_NamespacesInfo(personalNamespaces,otherUsersNamespaces,sharedNamespaces);
}
示例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.ReadToFirstChar();
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>
/// 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);
}
示例9: Parse
/// <summary>
/// Parses PERMANENTFLAGS optional response from string.
/// </summary>
/// <param name="r">PERMANENTFLAGS optional response reader.</param>
/// <returns>Returns PERMANENTFLAGS optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_PermanentFlags Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
if(!r.StartsWith("[PERMANENTFLAGS",false)){
throw new ArgumentException("Invalid PERMANENTFLAGS response value.","r");
}
// Read [
r.ReadSpecifiedLength(1);
// Read PERMANENTFLAGS
r.ReadWord();
r.ReadToFirstChar();
string[] flags = r.ReadParenthesized().Split(' ');
// Read ]
r.ReadSpecifiedLength(1);
return new IMAP_t_orc_PermanentFlags(flags);
}
示例10: Parse
/// <summary>
/// Parses search key from current position.
/// </summary>
/// <param name="reader"></param>
public void Parse(StringReader reader)
{
//Remove spaces from string start
reader.ReadToFirstChar();
if (reader.StartsWith("("))
{
reader = new StringReader(reader.ReadParenthesized().Trim());
}
//--- Start parsing search keys --------------//
while (reader.Available > 0)
{
object searchKey = ParseSearchKey(reader);
if (searchKey != null)
{
m_pSearchKeys.Add(searchKey);
}
}
//--------------------------------------------//
}
示例11: Parse
//.........这里部分代码省略.........
#region Subject
// Subject
word = r.ReadWord();
if(word == null){
throw new Exception("Invalid IMAP ENVELOPE structure !");
}
if(word.ToUpper() == "NIL"){
m_Subject = null;
}
else{
m_Subject = Core.CanonicalDecode(word);
}
#endregion
#region From
// From
m_From = ParseAddresses(r);
#endregion
#region Sender
// Sender
// NOTE: There is confusing part, according rfc 2822 Sender: is MailboxAddress and not AddressList.
MailboxAddress[] sender = ParseAddresses(r);
if(sender != null && sender.Length > 0){
m_Sender = sender[0];
}
else{
m_Sender = null;
}
#endregion
#region ReplyTo
// ReplyTo
m_ReplyTo = ParseAddresses(r);
#endregion
#region To
// To
m_To = ParseAddresses(r);
#endregion
#region Cc
// Cc
m_Cc = ParseAddresses(r);
#endregion
#region Bcc
// Bcc
m_Bcc = ParseAddresses(r);
#endregion
#region InReplyTo
// InReplyTo
r.ReadToFirstChar();
word = r.ReadWord();
if(word == null){
throw new Exception("Invalid IMAP ENVELOPE structure !");
}
if(word.ToUpper() == "NIL"){
m_InReplyTo = null;
}
else{
m_InReplyTo = word;
}
#endregion
#region MessageID
// MessageID
r.ReadToFirstChar();
word = r.ReadWord();
if(word == null){
throw new Exception("Invalid IMAP ENVELOPE structure !");
}
if(word.ToUpper() == "NIL"){
m_MessageID = null;
}
else{
m_MessageID = word;
}
#endregion
}
示例12: ParseKey
/// <summary>
/// Parses one search key or search key group.
/// </summary>
/// <param name="r">String reader.</param>
/// <returns>Returns one parsed search key or search key group.</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 ParseKey(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
r.ReadToFirstChar();
// Keys group
if(r.StartsWith("(",false)){
return IMAP_Search_Key_Group.Parse(new StringReader(r.ReadParenthesized()));
}
// ANSWERED
else if(r.StartsWith("ANSWERED",false)){
return IMAP_Search_Key_Answered.Parse(r);
}
// BCC
else if(r.StartsWith("BCC",false)){
return IMAP_Search_Key_Bcc.Parse(r);
}
// BEFORE
else if(r.StartsWith("BEFORE",false)){
return IMAP_Search_Key_Before.Parse(r);
}
// BODY
else if(r.StartsWith("BODY",false)){
return IMAP_Search_Key_Body.Parse(r);
}
// CC
else if(r.StartsWith("CC",false)){
return IMAP_Search_Key_Cc.Parse(r);
}
// DELETED
else if(r.StartsWith("DELETED",false)){
return IMAP_Search_Key_Deleted.Parse(r);
}
// DRAFT
else if(r.StartsWith("DRAFT",false)){
return IMAP_Search_Key_Draft.Parse(r);
}
// FLAGGED
else if(r.StartsWith("FLAGGED",false)){
return IMAP_Search_Key_Flagged.Parse(r);
}
// FROM
else if(r.StartsWith("FROM",false)){
return IMAP_Search_Key_From.Parse(r);
}
// HEADER
else if(r.StartsWith("HEADER",false)){
return IMAP_Search_Key_Header.Parse(r);
}
// KEYWORD
else if(r.StartsWith("KEYWORD",false)){
return IMAP_Search_Key_Keyword.Parse(r);
}
// LARGER
else if(r.StartsWith("LARGER",false)){
return IMAP_Search_Key_Larger.Parse(r);
}
// NEW
else if(r.StartsWith("NEW",false)){
return IMAP_Search_Key_New.Parse(r);
}
// NOT
else if(r.StartsWith("NOT",false)){
return IMAP_Search_Key_Not.Parse(r);
}
// OLD
else if(r.StartsWith("OLD",false)){
return IMAP_Search_Key_Old.Parse(r);
}
// ON
else if(r.StartsWith("ON",false)){
return IMAP_Search_Key_On.Parse(r);
}
// OR
else if(r.StartsWith("OR",false)){
return IMAP_Search_Key_Or.Parse(r);
}
// RECENT
else if(r.StartsWith("RECENT",false)){
return IMAP_Search_Key_Recent.Parse(r);
}
// SEEN
else if(r.StartsWith("SEEN",false)){
return IMAP_Search_Key_Seen.Parse(r);
}
// SENTBEFORE
else if(r.StartsWith("SENTBEFORE",false)){
return IMAP_Search_Key_SentBefore.Parse(r);
}
// SENTON
//.........这里部分代码省略.........
示例13: ParseNamespaces
private static IMAP_Namespace[] ParseNamespaces(string val)
{
StringReader r = new StringReader(val);
r.ReadToFirstChar();
List<IMAP_Namespace> namespaces = new List<IMAP_Namespace>();
while (r.StartsWith("("))
{
namespaces.Add(ParseNamespace(r.ReadParenthesized()));
}
return namespaces.ToArray();
}
示例14: Parse
/// <summary>
/// Parses NAMESPACE response from namespace-response string.
/// </summary>
/// <param name="response">NAMESPACE response string.</param>
/// <returns>Returns parsed NAMESPACE response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>response</b> is null reference.</exception>
public static IMAP_r_u_Namespace Parse(string response)
{
if(response == null){
throw new ArgumentNullException("response");
}
/* RFC 2342 5. NAMESPACE Command.
Arguments: none
Response: an untagged NAMESPACE response that contains the prefix
and hierarchy delimiter to the server's Personal
Namespace(s), Other Users' Namespace(s), and Shared
Namespace(s) that the server wishes to expose. The
response will contain a NIL for any namespace class
that is not available. Namespace_Response_Extensions
MAY be included in the response.
Namespace_Response_Extensions which are not on the IETF
standards track, MUST be prefixed with an "X-".
Result: OK - Command completed
NO - Error: Can't complete command
BAD - argument invalid
Example:
< A server that contains a Personal Namespace and a single Shared Namespace. >
C: A001 NAMESPACE
S: * NAMESPACE (("" "/")) NIL (("Public Folders/" "/"))
S: A001 OK NAMESPACE command completed
*/
StringReader r = new StringReader(response);
// Eat "*"
r.ReadWord();
// Eat "NAMESPACE"
r.ReadWord();
// Personal namespaces
r.ReadToFirstChar();
List<IMAP_Namespace_Entry> personal = new List<IMAP_Namespace_Entry>();
if(r.SourceString.StartsWith("(")){
StringReader rList = new StringReader(r.ReadParenthesized());
while(rList.Available > 0){
string[] items = TextUtils.SplitQuotedString(rList.ReadParenthesized(),' ',true);
personal.Add(new IMAP_Namespace_Entry(items[0],items[1][0]));
}
}
// NIL
else{
r.ReadWord();
}
// Other users namespaces
r.ReadToFirstChar();
List<IMAP_Namespace_Entry> other = new List<IMAP_Namespace_Entry>();
if(r.SourceString.StartsWith("(")){
StringReader rList = new StringReader(r.ReadParenthesized());
while(rList.Available > 0){
string[] items = TextUtils.SplitQuotedString(rList.ReadParenthesized(),' ',true);
other.Add(new IMAP_Namespace_Entry(items[0],items[1][0]));
}
}
// NIL
else{
r.ReadWord();
}
// Shared namespaces
r.ReadToFirstChar();
List<IMAP_Namespace_Entry> shared = new List<IMAP_Namespace_Entry>();
if(r.SourceString.StartsWith("(")){
StringReader rList = new StringReader(r.ReadParenthesized());
while(rList.Available > 0){
string[] items = TextUtils.SplitQuotedString(rList.ReadParenthesized(),' ',true);
shared.Add(new IMAP_Namespace_Entry(items[0],items[1][0]));
}
}
// NIL
else{
r.ReadWord();
}
return new IMAP_r_u_Namespace(personal.ToArray(),other.ToArray(),shared.ToArray());
}
示例15: Parse
/// <summary>
/// Parses "name-addr" or "addr-spec" 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 void Parse(StringReader reader)
{
/* RFC 3261.
name-addr = [ display-name ] LAQUOT addr-spec RAQUOT
addr-spec = SIP-URI / SIPS-URI / absoluteURI
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
reader.ReadToFirstChar();
// LAQUOT addr-spec RAQUOT
if(reader.StartsWith("<")){
m_pUri = AbsoluteUri.Parse(reader.ReadParenthesized());
}
else{
// Read while we get "<","," or EOF.
StringBuilder buf = new StringBuilder();
while(true){
buf.Append(reader.ReadToFirstChar());
string word = reader.ReadWord();
if(string.IsNullOrEmpty(word)){
break;
}
else{
buf.Append(word);
}
}
reader.ReadToFirstChar();
// name-addr
if(reader.StartsWith("<")){
m_DisplayName = buf.ToString().Trim();
m_pUri = AbsoluteUri.Parse(reader.ReadParenthesized());
}
// addr-spec
else{
m_pUri = AbsoluteUri.Parse(buf.ToString());
}
}
}