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

GetContentType() private method

Get the content type
private GetContentType ( string &sBodyStruct, string &sType, string &sSubType, string &sContentType ) : bool
sBodyStruct string Body Structure
sType string Content Type
sSubType string Sub Type
sContentType string Content Type Value
return bool
        bool GetContentType(ref string sBodyStruct,
            ref string sType,
            ref string sSubType,
            ref string sContentType)
        {
            sContentType = IMAP_PLAIN_TEXT;

            // get the type and the subtype strings from body struct
            // If not found, set it to the default value plain/text.

            if (sType.Length < 1)
            {
                if (!ParseQuotedString( ref sBodyStruct, ref sType ))
                {
                    Log(LogTypeEnum.ERROR, "Failed getting Content-Type.");
                    return false;
                }
            }
            sSubType = "";
            if (!ParseQuotedString( ref sBodyStruct, ref sSubType ))
            {
                Log(LogTypeEnum.ERROR, "Failed getting Content-Sub-Type.");
                return false;
            }

            if (sType.Length > 0 && sSubType.Length > 0 )
            {
                sContentType = sType + "/" + sSubType;
            }

            // Add extra parameters (if any) to the Content-type
            ArrayList asParam = new ArrayList();
            if (!ParseParameters( ref sBodyStruct, asParam ))
            {
                Log(LogTypeEnum.ERROR, "Failed getting Content-Type Parameters.");
                return false;
            }
            for (int i=0; i < asParam.Count; i+=2)
            {
                string sTemp = "; " + asParam[i].ToString() + "=\"" + asParam[i+1].ToString() + "\"";
                sContentType += sTemp;
            }
            return true;
        }