本文整理汇总了C#中StringReader.ReadParenthesized方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.ReadParenthesized方法的具体用法?C# StringReader.ReadParenthesized怎么用?C# StringReader.ReadParenthesized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringReader
的用法示例。
在下文中一共展示了StringReader.ReadParenthesized方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parses "Identity-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)
{
/*
Identity-Info = ident-info *( SEMI ident-info-params )
ident-info = LAQUOT absoluteURI RAQUOT
ident-info-params = ident-info-alg / ident-info-extension
ident-info-alg = "alg" EQUAL token
ident-info-extension = generic-param
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
// absoluteURI
try{
string word = reader.ReadParenthesized();
if(word == null){
throw new SIP_ParseException("Invalid Identity-Info 'absoluteURI' value !");
}
m_Uri = word;
}
catch{
throw new SIP_ParseException("Invalid Identity-Info 'absoluteURI' value !");
}
// Parse parameters
ParseParameters(reader);
}
示例2: Parse
/// <summary>
/// Parses LSUB response from lsub-response string.
/// </summary>
/// <param name="lSubResponse">LSub response string.</param>
/// <returns>Returns parsed lsub response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>lSubResponse</b> is null reference.</exception>
public static IMAP_r_u_LSub Parse(string lSubResponse)
{
if(lSubResponse == null){
throw new ArgumentNullException("lSubResponse");
}
/* RFC 3501 7.2.3. LSUB Response.
Contents: name attributes
hierarchy delimiter
name
The LSUB response occurs as a result of an LSUB command. It
returns a single name that matches the LSUB specification. There
can be multiple LSUB responses for a single LSUB command. The
data is identical in format to the LIST response.
Example: S: * LSUB () "." #news.comp.mail.misc
*/
StringReader r = new StringReader(lSubResponse);
// Eat "*"
r.ReadWord();
// Eat "LSUB"
r.ReadWord();
string attributes = r.ReadParenthesized();
string delimiter = r.ReadWord();
string folder = TextUtils.UnQuoteString(IMAP_Utils.DecodeMailbox(r.ReadToEnd().Trim()));
return new IMAP_r_u_LSub(folder,delimiter[0],attributes == string.Empty ? new string[0] : attributes.Split(' '));
}
示例3: Parse
/// <summary>
/// Parses COPYUID optional response from reader.
/// </summary>
/// <param name="r">COPYUID optional response reader.</param>
/// <returns>Returns COPYUID optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_CopyUid Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
/* RFC 4315 3.
COPYUID
Followed by the UIDVALIDITY of the destination mailbox, a UID set
containing the UIDs of the message(s) in the source mailbox that
were copied to the destination mailbox and containing the UIDs
assigned to the copied message(s) in the destination mailbox,
indicates that the message(s) have been copied to the destination
mailbox with the stated UID(s).
*/
string[] code_mailboxUid_sourceSeqSet_targetSeqSet = r.ReadParenthesized().Split(new char[]{' '},4);
if(!string.Equals("COPYUID",code_mailboxUid_sourceSeqSet_targetSeqSet[0],StringComparison.InvariantCultureIgnoreCase)){
throw new ArgumentException("Invalid COPYUID response value.","r");
}
if(code_mailboxUid_sourceSeqSet_targetSeqSet.Length != 4){
throw new ArgumentException("Invalid COPYUID response value.","r");
}
return new IMAP_t_orc_CopyUid(
Convert.ToInt64(code_mailboxUid_sourceSeqSet_targetSeqSet[1]),
IMAP_t_SeqSet.Parse(code_mailboxUid_sourceSeqSet_targetSeqSet[2]),
IMAP_t_SeqSet.Parse(code_mailboxUid_sourceSeqSet_targetSeqSet[3])
);
}
示例4: Parse
/// <summary>
/// Parses unknown optional response from reader.
/// </summary>
/// <param name="r">Unknown optional response reader.</param>
/// <returns>Returns unknown optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_Unknown Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
return new IMAP_t_orc_Unknown(r.ReadParenthesized());
}
示例5: Parse
/// <summary>
/// Parses TRYCREATE optional response from reader.
/// </summary>
/// <param name="r">TRYCREATE optional response reader.</param>
/// <returns>Returns TRYCREATE optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_TryCreate Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
string[] code_value = r.ReadParenthesized().Split(new char[]{' '},2);
if(!string.Equals("TRYCREATE",code_value[0],StringComparison.InvariantCultureIgnoreCase)){
throw new ArgumentException("Invalid TRYCREATE response value.","r");
}
return new IMAP_t_orc_TryCreate();
}
示例6: Parse
/// <summary>
/// Parses BADCHARSET optional response from reader.
/// </summary>
/// <param name="r">BADCHARSET optional response reader.</param>
/// <returns>Returns BADCHARSET optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_BadCharset Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
string[] code_value = r.ReadParenthesized().Split(new char[]{' '},2);
if(!string.Equals("BADCHARSET",code_value[0],StringComparison.InvariantCultureIgnoreCase)){
throw new ArgumentException("Invalid BADCHARSET response value.","r");
}
return new IMAP_t_orc_BadCharset(code_value[1].Trim().Split(' '));
}
示例7: Parse
/// <summary>
/// Parses ALERT optional response from reader.
/// </summary>
/// <param name="r">ALERT optional response reader.</param>
/// <returns>Returns ALERT optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_Alert Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
string[] code_value = r.ReadParenthesized().Split(new char[]{' '},2);
if(!string.Equals("ALERT",code_value[0],StringComparison.InvariantCultureIgnoreCase)){
throw new ArgumentException("Invalid ALERT response value.","r");
}
return new IMAP_t_orc_Alert(code_value.Length == 2 ? code_value[1] : "");
}
示例8: Parse
/// <summary>
/// Parses STATUS response from status-response string.
/// </summary>
/// <param name="response">Satatus response string.</param>
/// <returns>Returns parsed STATUS response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>response</b> is null reference.</exception>
public static IMAP_r_u_Status Parse(string response)
{
if(response == null){
throw new ArgumentNullException("response");
}
/* RFC 3501 7.2.4 STATUS Response.
Contents: name
status parenthesized list
The STATUS response occurs as a result of an STATUS command. It
returns the mailbox name that matches the STATUS specification and
the requested mailbox status information.
Example: S: * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292)
*/
StringReader r = new StringReader(response);
// Eat "*"
r.ReadWord();
// Eat "STATUS"
r.ReadWord();
int messages = 0;
int recent = 0;
long uidNext = 0;
long folderUid = 0;
int unseen = 0;
string folder = TextUtils.UnQuoteString(IMAP_Utils.Decode_IMAP_UTF7_String(r.ReadWord()));
string[] items = r.ReadParenthesized().Split(' ');
for(int i=0;i<items.Length;i+=2){
if(items[i].Equals("MESSAGES",StringComparison.InvariantCultureIgnoreCase)){
messages = Convert.ToInt32(items[i + 1]);
}
else if(items[i].Equals("RECENT",StringComparison.InvariantCultureIgnoreCase)){
recent = Convert.ToInt32(items[i + 1]);
}
else if(items[i].Equals("UIDNEXT",StringComparison.InvariantCultureIgnoreCase)){
uidNext = Convert.ToInt64(items[i + 1]);
}
else if(items[i].Equals("UIDVALIDITY",StringComparison.InvariantCultureIgnoreCase)){
folderUid = Convert.ToInt64(items[i + 1]);
}
else if(items[i].Equals("UNSEEN",StringComparison.InvariantCultureIgnoreCase)){
unseen = Convert.ToInt32(items[i + 1]);
}
}
return new IMAP_r_u_Status(folder,messages,recent,uidNext,folderUid,unseen);
}
示例9: Parse
/// <summary>
/// Parses UNSEEN optional response from reader.
/// </summary>
/// <param name="r">UNSEEN optional response reader.</param>
/// <returns>Returns UNSEEN optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_Unseen Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
string[] code_value = r.ReadParenthesized().Split(new char[]{' '},2);
if(!string.Equals("UNSEEN",code_value[0],StringComparison.InvariantCultureIgnoreCase)){
throw new ArgumentException("Invalid UNSEEN response value.","r");
}
if(code_value.Length != 2){
throw new ArgumentException("Invalid UNSEEN response value.","r");
}
return new IMAP_t_orc_Unseen(Convert.ToInt32(code_value[1]));
}
示例10: Parse
/// <summary>
/// Parses CAPABILITY optional response from reader.
/// </summary>
/// <param name="r">CAPABILITY optional response reader.</param>
/// <returns>Returns CAPABILITY optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>r</b> is null reference.</exception>
public new static IMAP_t_orc_Capability Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
string[] code_value = r.ReadParenthesized().Split(new char[]{' '},2);
if(!string.Equals("CAPABILITY",code_value[0],StringComparison.InvariantCultureIgnoreCase)){
throw new ArgumentException("Invalid CAPABILITY response value.","r");
}
if(code_value.Length != 2){
throw new ArgumentException("Invalid CAPABILITY response value.","r");
}
return new IMAP_t_orc_Capability(code_value[1].Split(' '));
}
示例11: Parse
/// <summary>
/// Parses PERMANENTFLAGS optional response from string.
/// </summary>
/// <param name="value">PERMANENTFLAGS optional response string.</param>
/// <returns>Returns PERMANENTFLAGS optional response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>value</b> is null reference.</exception>
public new static IMAP_t_orc_PermanentFlags Parse(string value)
{
if(value == null){
throw new ArgumentNullException("value");
}
string[] code_value = value.Split(new char[]{' '},2);
if(!string.Equals("PERMANENTFLAGS",code_value[0],StringComparison.InvariantCultureIgnoreCase)){
throw new ArgumentException("Invalid PERMANENTFLAGS response value.","value");
}
if(code_value.Length != 2){
throw new ArgumentException("Invalid PERMANENTFLAGS response value.","value");
}
StringReader r = new StringReader(code_value[1]);
r.ReadWord();
return new IMAP_t_orc_PermanentFlags(r.ReadParenthesized().Split(' '));
}
示例12: 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);
}
示例13: Parse
/// <summary>
/// Returns parsed IMAP SEARCH <b>AND</b> key group.
/// </summary>
/// <param name="r">String reader.</param>
/// <returns>Returns parsed IMAP SEARCH <b>AND</b> 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>
public static IMAP_Search_Key_Group Parse(StringReader r)
{
if(r == null){
throw new ArgumentNullException("r");
}
// Remove parenthesis, if any.
if(r.StartsWith("(")){
r = new StringReader(r.ReadParenthesized());
}
IMAP_Search_Key_Group retVal = new IMAP_Search_Key_Group();
r.ReadToFirstChar();
while(r.Available > 0){
retVal.m_pKeys.Add(IMAP_Search_Key.ParseKey(r));
}
return retVal;
}
示例14: Parse
/// <summary>
/// Parses QUOTA response from quota-response string.
/// </summary>
/// <param name="response">QUOTA response string.</param>
/// <returns>Returns parsed QUOTA response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>response</b> is null reference.</exception>
public static IMAP_r_u_Quota Parse(string response)
{
if(response == null){
throw new ArgumentNullException("response");
}
/* RFC 2087 5.1. QUOTA Response.
Data: quota root name
list of resource names, usages, and limits
This response occurs as a result of a GETQUOTA or GETQUOTAROOT
command. The first string is the name of the quota root for which
this quota applies.
The name is followed by a S-expression format list of the resource
usage and limits of the quota root. The list contains zero or
more triplets. Each triplet conatins a resource name, the current
usage of the resource, and the resource limit.
Resources not named in the list are not limited in the quota root.
Thus, an empty list means there are no administrative resource
limits in the quota root.
Example: S: * QUOTA "" (STORAGE 10 512)
*/
StringReader r = new StringReader(response);
// Eat "*"
r.ReadWord();
// Eat "QUOTA"
r.ReadWord();
string name = r.ReadWord();
string[] items = r.ReadParenthesized().Split(' ');
List<IMAP_Quota_Entry> entries = new List<IMAP_Quota_Entry>();
for(int i=0;i<items.Length;i+=3){
entries.Add(new IMAP_Quota_Entry(items[i],Convert.ToInt64(items[i + 1]),Convert.ToInt64(items[i + 2])));
}
return new IMAP_r_u_Quota(name,entries.ToArray());
}
示例15: 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);
}
}
//--------------------------------------------//
}