/// <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_ServerStatus Parse(string responseLine) { if (responseLine == null) { throw new ArgumentNullException("responseLine"); } // We continuation "+" response. if (responseLine.StartsWith("+")) { string[] parts = responseLine.Split(new char[] { ' ' }, 2); string responseText = parts.Length == 2 ? parts[1] : null; return(new IMAP_r_ServerStatus("+", "+", responseText)); } // OK/BAD/NO else { 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.ReadParenthesized()); responseText = r.ReadToEnd(); } return(new IMAP_r_ServerStatus(commandTag, responseCode, optResponse, responseText)); } }
/// <summary> /// Default constructor. /// </summary> /// <param name="commandTag">Command tag.</param> /// <param name="responseCode">Response code.</param> /// <param name="optionalResponse">Optional response. Value null means not specified.</param> /// <param name="responseText">Response text after response-code.</param> /// <exception cref="ArgumentNullException">Is raised when <b>commandTag</b>,<b>responseCode</b> or <b>responseText</b> is null reference.</exception> /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception> public IMAP_r_ServerStatus(string commandTag, string responseCode, IMAP_t_orc optionalResponse, string responseText) { if (commandTag == null) { throw new ArgumentNullException("commandTag"); } if (commandTag == string.Empty) { throw new ArgumentException("The argument 'commandTag' value must be specified.", "commandTag"); } if (responseCode == null) { throw new ArgumentNullException("responseCode"); } if (responseCode == string.Empty) { throw new ArgumentException("The argument 'responseCode' value must be specified.", "responseCode"); } m_CommandTag = commandTag; m_ResponseCode = responseCode; m_pOptionalResponse = optionalResponse; m_ResponseText = responseText; }