Пример #1
0
        // ------------------------- Crack ------------------------------------
        // crack the mail drop LIST line into its message number and size components.
        public MailDropMessage Crack(string InLine)
        {
            mRawLine = InLine;

            WordCursor csr = new WordCursor( )
                             .SetString(InLine);

            csr       = csr.NextWord( );
            MessageNx = csr.Word.ToString( );
            csr       = csr.NextWord( );
            MessageSx = csr.Word.ToString( );

            return(this);
        }
Пример #2
0
        // ------------------------- ParseContentType ----------------------------
        public static PartProperty.ContentType ParseContentType(string InString)
        {
            TextTraits traits = new TextTraits()
                                .SetQuoteEncapsulation(QuoteEncapsulation.Escape);

            traits.DividerPatterns.Replace(
                new string[] { "/", ":", ";", " ", "\t", "=" }, DelimClassification.DividerSymbol);
            traits.WhitespacePatterns.Replace(" ", "\t", DelimClassification.Whitespace);
            PartProperty.ContentType results = new PartProperty.ContentType();

            WordCursor csr = Scanner.PositionBeginWord(InString, traits);

            while (true)
            {
                csr = Scanner.ScanNextWord(InString, csr);
                if (csr.IsEndOfString)
                {
                    break;
                }

                // content type
                if (csr.DelimValue == "/")
                {
                    results.Type = csr.Word.ToString( ).ToLower( );
                }

                // content sub type.
                else if (csr.DelimValue == ";")
                {
                    results.SubType = csr.Word.ToString( ).ToLower( );
                }

                // a kwd
                else if (csr.DelimValue == "=")
                {
                    WordCursor nxCsr = csr.NextWord( );
                    if ((nxCsr.DelimClass == DelimClassification.EndOfString) ||
                        (nxCsr.DelimClass == DelimClassification.Whitespace))
                    {
                        string kwd = csr.Word.ToString( ).ToLower( );
                        csr = nxCsr;
                        if (kwd == "charset")
                        {
                            results.CharSet = csr.Word.NonQuotedSimpleValue;
                        }
                        else if (kwd == "boundary")
                        {
                            results.Boundary = csr.Word.NonQuotedSimpleValue;
                        }
                        else if (kwd == "name")
                        {
                            results.Name = csr.Word.NonQuotedSimpleValue;
                        }
                    }
                }
            }
            return(results);
        }
Пример #3
0
        ParseContentDisposition(string InString)
        {
            TextTraits traits = new TextTraits()
                                .SetQuoteEncapsulation(QuoteEncapsulation.Escape);

            traits.DividerPatterns.Replace(
                new string[] { ";", " ", "\t", "=" }, DelimClassification.DividerSymbol);
            traits.WhitespacePatterns.Replace(" ", "\t", DelimClassification.Whitespace);
            PartProperty.ContentDisposition results = new PartProperty.ContentDisposition();

            WordCursor csr = Scanner.PositionBeginWord(InString, traits);

            while (true)
            {
                csr = Scanner.ScanNextWord(InString, csr);
                if (csr.IsEndOfString)
                {
                    break;
                }

                // content disposition
                if (csr.DelimValue == ";")
                {
                    results.Disposition = csr.Word.ToString( ).ToLower( );
                }

                // a kwd
                else if (csr.DelimValue == "=")
                {
                    WordCursor nxCsr = csr.NextWord( );
                    if ((nxCsr.DelimClass == DelimClassification.EndOfString) ||
                        (nxCsr.DelimClass == DelimClassification.Whitespace))
                    {
                        string kwd = csr.Word.ToString( ).ToLower( );
                        csr = nxCsr;
                        if (kwd == "filename")
                        {
                            results.FileName = csr.Word.NonQuotedSimpleValue;
                        }
                    }
                }
            }
            return(results);
        }