Joshi.Utils.Imap.Imap.GetResponseSize C# (CSharp) Method

GetResponseSize() private method

Get the Size of the fetch command response response will look like "{}"
private GetResponseSize ( string sResponse ) : long
sResponse string
return long
        long GetResponseSize(string sResponse)
        {
            // check if there is a size element
            // if not, then the message part number is wrong

            if (sResponse.IndexOf(IMAP_MESSAGE_NIL) != -1)
            {
                Log(LogTypeEnum.ERROR, "Size 0. No Message after this.");
                return 0L;
            }

            int nStart = sResponse.IndexOf('{');
            if (nStart == -1)
            {
                string sLog = "Invalid size in Response " + sResponse + ".";
                Log(LogTypeEnum.ERROR,sLog);
                throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_INVALIDHEADER);
            }
            int nEnd = sResponse.IndexOf('}');
            if (nEnd == -1 || nEnd < nStart)
            {
                string sLog = "Invalid size in Response " + sResponse + ".";
                Log(LogTypeEnum.ERROR,sLog);
                throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_INVALIDHEADER);
            }

            string sSize = sResponse.Substring( nStart+1, (nEnd - nStart -1));
            long nSize = Convert.ToInt64(sSize, 10 );

            if ( nSize <= 0L )
            {
                string sLog = "Invalid size in Response " + sResponse + ".";
                Log(LogTypeEnum.ERROR,sLog);
                throw new ImapException(ImapException.ImapErrorEnum.IMAP_ERR_INVALIDHEADER);
            }

            return nSize;
        }