コード例 #1
0
        /// <summary>
        /// Sets the article cursor.
        /// </summary>
        /// <param name="direction">The direction.</param>
        /// <returns></returns>
        private ArticleResponseIds SetArticleCursor(string direction)
        {
            if (direction == null)
            {
                throw new ArgumentNullException("direction");
            }

            if (!(direction.Equals("LAST", StringComparison.InvariantCultureIgnoreCase) || direction.Equals("NEXT", StringComparison.InvariantCultureIgnoreCase)))
            {
                throw new ArgumentException(Resource.ErrorMessage03, "direction");
            }

            if (!CurrentGroupSelected)
            {
                throw new NntpGroupNotSelectedException();
            }

            ValidateConnectionState();

            NntpReaderWriter.WriteCommand(direction);
            NntpReaderWriter.ReadResponse();
            if (NntpReaderWriter.LastResponseCode != Rfc977ResponseCodes.ArticleRetrievedTextSeparate)
            {
                throw new NntpResponseException(Resource.ErrorMessage04, NntpReaderWriter.LastResponse);
            }
            return(ArticleResponseIds.Parse(NntpReaderWriter.LastResponse));
        }
コード例 #2
0
        /// <summary>
        /// Parses the specified response.
        /// </summary>
        /// <param name="response">The response.</param>
        /// <returns></returns>
        public static ArticleResponseIds Parse(string response)
        {
            if (string.IsNullOrEmpty(response))
            {
                throw new ArgumentNullException("response");
            }
            ArticleResponseIds a = new ArticleResponseIds();

            string[] sa = response.Split(new char[] { ' ' });
            if (sa.Length == 2)
            {
                a.m_articleId = Rfc977NntpClient.ConvertToInt32(sa[0]);
                a.m_messageId = sa[1];
            }
            else if (sa.Length > 2)
            {
                a.m_articleId = Rfc977NntpClient.ConvertToInt32(sa[1]);
                a.m_messageId = sa[2];
            }
            else
            {
                throw new ArgumentException(Resource.ErrorMessage48, "response");
            }
            return(a);
        }
コード例 #3
0
        /// <summary>
        /// Retrieves the statistics for an article based on the command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <returns></returns>
        protected virtual ArticleResponseIds RetrieveStatisticsCore(string command)
        {
            ValidateConnectionState();

            if (!CurrentGroupSelected)
            {
                throw new NntpGroupNotSelectedException();
            }

            NntpReaderWriter.WriteCommand(command);
            NntpReaderWriter.ReadResponse();
            if (NntpReaderWriter.LastResponseCode != Rfc977ResponseCodes.ArticleRetrievedTextSeparate)
            {
                throw new NntpResponseException(Resource.ErrorMessage05, NntpReaderWriter.LastResponse);
            }
            return(ArticleResponseIds.Parse(NntpReaderWriter.LastResponse));
        }
コード例 #4
0
 /// <summary>
 /// Parses the specified response.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <returns></returns>
 public static ArticleResponseIds Parse(string response)
 {
     if (string.IsNullOrEmpty(response))
     {
         throw new ArgumentNullException("response");
     }
     ArticleResponseIds a = new ArticleResponseIds();
     string[] sa = response.Split(new char[] { ' ' });
     if (sa.Length == 2)
     {
         a.m_articleId = Rfc977NntpClient.ConvertToInt32(sa[0]);
         a.m_messageId = sa[1];
     }
     else if (sa.Length > 2)
     {
         a.m_articleId = Rfc977NntpClient.ConvertToInt32(sa[1]);
         a.m_messageId = sa[2];
     }
     else
     {
         throw new ArgumentException(Resource.ErrorMessage48, "response");
     }
     return a;
 }