本文整理汇总了C#中StringReader.ReadToEnd方法的典型用法代码示例。如果您正苦于以下问题:C# StringReader.ReadToEnd方法的具体用法?C# StringReader.ReadToEnd怎么用?C# StringReader.ReadToEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringReader
的用法示例。
在下文中一共展示了StringReader.ReadToEnd方法的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 ENABLE response from enable-response string.
/// </summary>
/// <param name="enableResponse">Enable response string.</param>
/// <returns>Returns parsed ENABLE response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>enableResponse</b> is null reference.</exception>
public static IMAP_r_u_Enable Parse(string enableResponse)
{
if(enableResponse == null){
throw new ArgumentNullException("enableResponse");
}
/* RFC 5161 4. Formal Syntax
The following syntax specification uses the Augmented Backus-Naur
Form (ABNF) notation as specified in [RFC5234] including the core
rules in Appendix B.1. [RFC3501] defines the non-terminals
"capability" and "command-any".
Except as noted otherwise, all alphabetic characters are
case-insensitive. The use of upper or lower case characters to
define token strings is for editorial clarity only. Implementations
MUST accept these strings in a case-insensitive fashion.
capability =/ "ENABLE"
command-any =/ "ENABLE" 1*(SP capability)
response-data =/ "*" SP enable-data CRLF
enable-data = "ENABLED" *(SP capability)
*/
StringReader r = new StringReader(enableResponse);
// Eat "*"
r.ReadWord();
// Eat "ENABLED"
r.ReadWord();
return new IMAP_r_u_Enable(r.ReadToEnd().Split(' '));
}
示例3: Parse
/// <summary>
/// Parses MYRIGHTS response from MYRIGHTS-response string.
/// </summary>
/// <param name="myRightsResponse">MYRIGHTS response line.</param>
/// <returns>Returns parsed MYRIGHTS response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>myRightsResponse</b> is null reference.</exception>
public static IMAP_Response_MyRights Parse(string myRightsResponse)
{
if(myRightsResponse == null){
throw new ArgumentNullException("myRightsResponse");
}
/* RFC 4314 3.8. MYRIGHTS Response.
Data: mailbox name
rights
The MYRIGHTS response occurs as a result of a MYRIGHTS command. The
first string is the mailbox name for which these rights apply. The
second string is the set of rights that the client has.
Section 2.1.1 details additional server requirements related to
handling of the virtual "d" and "c" rights.
Example: C: A003 MYRIGHTS INBOX
S: * MYRIGHTS INBOX rwiptsldaex
S: A003 OK Myrights complete
*/
StringReader r = new StringReader(myRightsResponse);
// Eat "*"
r.ReadWord();
// Eat "MYRIGHTS"
r.ReadWord();
string folder = IMAP_Utils.Decode_IMAP_UTF7_String(r.ReadWord(true));
string rights = r.ReadToEnd().Trim();
return new IMAP_Response_MyRights(folder,rights);
}
示例4: 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(' '));
}
示例5: runTest
public bool runTest()
{
Console.WriteLine(s_strTFPath + "\\" + s_strTFName + " , for " + s_strClassMethod + " , Source ver " + s_strDtTmVer);
int iCountErrors = 0;
int iCountTestcases = 0;
String strLoc = "Loc_000oo";
String strValue = String.Empty;
try
{
StringReader sr;
strLoc = "Loc_98yg7";
iCountTestcases++;
try {
sr = new StringReader(null);
String strTemp = sr.ReadToEnd();
iCountErrors++;
printerr( "Error_18syx! StringReader should only hold null");
sr.ReadLine();
sr.Peek();
sr.Read();
sr.Close();
} catch (ArgumentNullException exc) {
printinfo("Expected exception thrown, exc=="+exc.Message);
}catch (Exception exc) {
iCountErrors++;
printerr("Error_109xu! Unexpected exception thrown, exc=="+exc.ToString());
}
strLoc = "Loc_4790s";
sr = new StringReader(String.Empty);
iCountTestcases++;
if(!sr.ReadToEnd().Equals(String.Empty)) {
iCountErrors++;
printerr( "Error_099xa! Incorrect construction");
}
strLoc = "Loc_8388x";
sr = new StringReader("Hello\0World");
iCountTestcases++;
if(!sr.ReadToEnd().Equals("Hello\0World")) {
iCountErrors++;
printerr( "Error_1099f! Incorrect construction");
}
} catch (Exception exc_general ) {
++iCountErrors;
Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy! strLoc=="+ strLoc +", exc_general=="+exc_general.ToString());
}
if ( iCountErrors == 0 )
{
Console.WriteLine( "paSs. "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
return true;
}
else
{
Console.WriteLine("FAiL! "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
return false;
}
}
示例6: SerializeXml
/// <summary>
/// An object extension method that serialize a string to XML.
/// </summary>
/// <param name="this">The @this to act on.</param>
/// <returns>The string representation of the Xml Serialization.</returns>
public static string SerializeXml(this object @this)
{
var xmlSerializer = new XmlSerializer(@this.GetType());
using (var stringWriter = new StringWriter())
{
xmlSerializer.Serialize(stringWriter, @this);
using (var streamReader = new StringReader(stringWriter.GetStringBuilder().ToString()))
{
return streamReader.ReadToEnd();
}
}
}
示例7: Parse
/// <summary>
/// Parses BYE response from bye-response string.
/// </summary>
/// <param name="byeResponse">Bye response string.</param>
/// <returns>Returns parsed BYE response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>byeResponse</b> is null reference.</exception>
public static IMAP_r_u_Bye Parse(string byeResponse)
{
if(byeResponse == null){
throw new ArgumentNullException("byeResponse");
}
/* RFC 3501 7.1.5. BYE Response.
Contents: OPTIONAL response code
human-readable text
The BYE response is always untagged, and indicates that the server
is about to close the connection. The human-readable text MAY be
displayed to the user in a status report by the client. The BYE
response is sent under one of four conditions:
1) as part of a normal logout sequence. The server will close
the connection after sending the tagged OK response to the
LOGOUT command.
2) as a panic shutdown announcement. The server closes the
connection immediately.
3) as an announcement of an inactivity autologout. The server
closes the connection immediately.
4) as one of three possible greetings at connection startup,
indicating that the server is not willing to accept a
connection from this client. The server closes the
connection immediately.
The difference between a BYE that occurs as part of a normal
LOGOUT sequence (the first case) and a BYE that occurs because of
a failure (the other three cases) is that the connection closes
immediately in the failure case. In all cases the client SHOULD
continue to read response data from the server until the
connection is closed; this will ensure that any pending untagged
or completion responses are read and processed.
Example: S: * BYE Autologout; idle for too long
*/
StringReader r = new StringReader(byeResponse);
// Eat "*"
r.ReadWord();
// Eat "BYE"
r.ReadWord();
return new IMAP_r_u_Bye(r.ReadToEnd());
}
示例8: LoadTable
public override void LoadTable(string _path)
{
try
{
XmlElement root = null;
#if LOCAL_TEST
XmlDocument xmlDoc = new XmlDocument();
TextAsset xmlText = Resources.Load(_path) as TextAsset;
byte[] encodedString = Encoding.UTF8.GetBytes(xmlText.text);
MemoryStream memoryStream = new MemoryStream(encodedString);
StreamReader streamReader = new StreamReader(memoryStream);
StringReader stringReader = new StringReader(streamReader.ReadToEnd());
string str = stringReader.ReadToEnd();
xmlDoc.LoadXml(str);
root = xmlDoc.DocumentElement;
#else
root = GetXmlRootElement(_path);
#endif
// 파일이 없다
if (root == null)
throw new Exception("File is not exist = " + _path);
XmlNode topNode = root.SelectSingleNode("Charge");
XmlNodeList nodes = topNode.ChildNodes;
foreach (XmlNode node in nodes)
{
Tbl_ChargeRecord record = new Tbl_ChargeRecord((XmlElement)node);
if (m_ResourceTable.ContainsKey(record.itemID) == false)
{
m_ResourceTable.Add(record.itemID, record);
Debug.LogWarning("Add = " + record.itemID);
}
}
}
catch (System.Exception e)
{
System.Diagnostics.Trace.WriteLine(e);
}
}
示例9: Parse
/// <summary>
/// Parses IMAP command completion status response from response line.
/// </summary>
/// <param name="responseLine">Response line.</param>
/// <returns>Returns parsed IMAP command completion status response.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>responseLine</b> is null reference value.</exception>
public static IMAP_r_u_ServerStatus Parse(string responseLine)
{
if(responseLine == null){
throw new ArgumentNullException("responseLine");
}
string[] parts = responseLine.Split(new char[]{' '},3);
string commandTag = parts[0];
string responseCode = parts[1];
IMAP_t_orc optResponse = null;
string responseText = parts[2];
// Optional status code.
if(parts[2].StartsWith("[")){
StringReader r = new StringReader(parts[2]);
optResponse = IMAP_t_orc.Parse(r);
responseText = r.ReadToEnd();
}
return new IMAP_r_u_ServerStatus(responseCode,optResponse,responseText);
}
示例10: Parse
/// <summary>
/// Parses "challenge" from specified reader.
/// </summary>
/// <param name="reader">Reader what contains challenge 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)
{
// challenge = ("Digest" LWS digest-cln *(COMMA digest-cln)) / other-challenge
if(reader == null){
throw new ArgumentNullException("reader");
}
// Get authentication method
string word = reader.ReadWord();
if(word == null){
throw new SIP_ParseException("Invalid WWW-Authenticate: value, authentication method is missing !");
}
m_Method = word;
// Get authentication data
word = reader.ReadToEnd();
if(word == null){
throw new SIP_ParseException("Invalid WWW-Authenticate: value, authentication parameters are missing !");
}
m_AuthData = word.Trim();
}
示例11: Parse
/// <summary>
/// Parses "credentials" 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)
{
/*
credentials = ("Digest" LWS digest-response) / other-response
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
// Get authentication method
string word = reader.ReadWord();
if(word == null){
throw new SIP_ParseException("Invalid 'credentials' value, authentication method is missing !");
}
m_Method = word;
// Get authentication data
word = reader.ReadToEnd();
if(word == null){
throw new SIP_ParseException("Invalid 'credentials' value, authentication parameters are missing !");
}
m_AuthData = word.Trim();
}
示例12: Parse
/// <summary>
/// Parses ACL response from acl-response string.
/// </summary>
/// <param name="aclResponse">ACL response.</param>
/// <returns>Returns parsed ACL response.</returns>
/// <exception cref="ArgumentNullException">Is raised wehn <b>aclResponse</b> is null reference.</exception>
public static IMAP_r_u_Acl Parse(string aclResponse)
{
if(aclResponse == null){
throw new ArgumentNullException("aclResponse");
}
/* RFC 4314 3.6. ACL Response.
Data: mailbox name
zero or more identifier rights pairs
The ACL response occurs as a result of a GETACL command. The first
string is the mailbox name for which this ACL applies. This is
followed by zero or more pairs of strings; each pair contains the
identifier for which the entry applies followed by the set of rights
that the identifier has.
Example: C: A002 GETACL INBOX
S: * ACL INBOX Fred rwipsldexta
S: A002 OK Getacl complete
*/
StringReader r = new StringReader(aclResponse);
// Eat "*"
r.ReadWord();
// Eat "ACL"
r.ReadWord();
string folderName = TextUtils.UnQuoteString(IMAP_Utils.Decode_IMAP_UTF7_String(r.ReadWord()));
string[] items = r.ReadToEnd().Split(' ');
List<IMAP_Acl_Entry> entries = new List<IMAP_Acl_Entry>();
for(int i=0;i<items.Length;i+=2){
entries.Add(new IMAP_Acl_Entry(items[i],items[i + 1]));
}
return new IMAP_r_u_Acl(folderName,entries.ToArray());
}
示例13: ReadToEndReadsTheEntireString
public void ReadToEndReadsTheEntireString()
{
// Arrange
var stringReader = new StringReader("123 Hello\r\n 123 world");
// Act
stringReader.ReadInt();
string output = stringReader.ReadToEnd();
// Assert
Assert.Equal(" Hello\r\n 123 world", output);
}
示例14: Parse
/// <summary>
/// Parses "warning-value" 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)
{
/*
warning-value = warn-code SP warn-agent SP warn-text
warn-code = 3DIGIT
warn-agent = hostport / pseudonym
; the name or pseudonym of the server adding
; the Warning header, for use in debugging
warn-text = quoted-string
pseudonym = token
*/
if(reader == null){
throw new ArgumentNullException("reader");
}
string word = reader.ReadWord();
if(word == null){
throw new SIP_ParseException("Invalid 'warning-value' value, warn-code is missing !");
}
try{
this.Code = Convert.ToInt32(word);
}
catch{
throw new SIP_ParseException("Invalid 'warning-value' warn-code value, warn-code is missing !");
}
word = reader.ReadWord();
if(word == null){
throw new SIP_ParseException("Invalid 'warning-value' value, warn-agent is missing !");
}
this.Agent = word;
word = reader.ReadToEnd();
if(word == null){
throw new SIP_ParseException("Invalid 'warning-value' value, warn-text is missing !");
}
this.Agent = TextUtils.UnQuoteString(word);
}
示例15: Parse
/// <summary>
/// Parses CAPABILITY response from capability-response string.
/// </summary>
/// <param name="response">Capability response string.</param>
/// <returns>Returns parsed CAPABILITY response.</returns>
/// <exception cref="ArgumentNullException">Is riased when <b>response</b> is null reference.</exception>
public static IMAP_r_u_Capability Parse(string response)
{
if(response == null){
throw new ArgumentNullException("response");
}
/* RFC 3501 7.2.1. CAPABILITY Response.
Contents: capability listing
The CAPABILITY response occurs as a result of a CAPABILITY
command. The capability listing contains a space-separated
listing of capability names that the server supports. The
capability listing MUST include the atom "IMAP4rev1".
In addition, client and server implementations MUST implement the
STARTTLS, LOGINDISABLED, and AUTH=PLAIN (described in [IMAP-TLS])
capabilities. See the Security Considerations section for
important information.
A capability name which begins with "AUTH=" indicates that the
server supports that particular authentication mechanism.
The LOGINDISABLED capability indicates that the LOGIN command is
disabled, and that the server will respond with a tagged NO
response to any attempt to use the LOGIN command even if the user
name and password are valid. An IMAP client MUST NOT issue the
LOGIN command if the server advertises the LOGINDISABLED
capability.
Other capability names indicate that the server supports an
extension, revision, or amendment to the IMAP4rev1 protocol.
Server responses MUST conform to this document until the client
issues a command that uses the associated capability.
Capability names MUST either begin with "X" or be standard or
standards-track IMAP4rev1 extensions, revisions, or amendments
registered with IANA. A server MUST NOT offer unregistered or
non-standard capability names, unless such names are prefixed with
an "X".
Client implementations SHOULD NOT require any capability name
other than "IMAP4rev1", and MUST ignore any unknown capability
names.
A server MAY send capabilities automatically, by using the
CAPABILITY response code in the initial PREAUTH or OK responses,
and by sending an updated CAPABILITY response code in the tagged
OK response as part of a successful authentication. It is
unnecessary for a client to send a separate CAPABILITY command if
it recognizes these automatic capabilities.
Example: S: * CAPABILITY IMAP4rev1 STARTTLS AUTH=GSSAPI XPIG-LATIN
*/
StringReader r = new StringReader(response);
// Eat "*"
r.ReadWord();
// Eat "CAPABILITY"
r.ReadWord();
string[] capabilities = r.ReadToEnd().Split(' ');
return new IMAP_r_u_Capability(capabilities);
}