Ejemplo n.º 1
0
        // Token: 0x0600053D RID: 1341 RVA: 0x0001CC64 File Offset: 0x0001AE64
        public static MimeRecipient Parse(string address, AddressParserFlags flags)
        {
            MimeRecipient mimeRecipient = new MimeRecipient();

            if (!string.IsNullOrEmpty(address))
            {
                byte[]            array             = ByteString.StringToBytes(address, true);
                MimeAddressParser mimeAddressParser = new MimeAddressParser();
                mimeAddressParser.Initialize(new MimeStringList(array, 0, array.Length), AddressParserFlags.None != (flags & AddressParserFlags.IgnoreComments), AddressParserFlags.None != (flags & AddressParserFlags.AllowSquareBrackets), true);
                MimeStringList displayNameFragments = default(MimeStringList);
                mimeAddressParser.ParseNextMailbox(ref displayNameFragments, ref mimeRecipient.emailAddressFragments);
                MimeRecipient.ConvertDisplayNameBack(mimeRecipient, displayNameFragments, true);
            }
            return(mimeRecipient);
        }
Ejemplo n.º 2
0
        // Token: 0x06000191 RID: 401 RVA: 0x000072A8 File Offset: 0x000054A8
        internal MimeNode ParseNextMailBox(bool fromGroup)
        {
            if (this.parsed)
            {
                return(null);
            }
            DecodingOptions headerDecodingOptions = base.GetHeaderDecodingOptions();

            if (this.parser == null)
            {
                this.parser = new MimeAddressParser();
            }
            if (!this.parser.Initialized)
            {
                this.parser.Initialize(base.Lines, false, false, headerDecodingOptions.AllowUTF8);
            }
            MimeStringList      displayNameFragments = default(MimeStringList);
            MimeStringList      mimeStringList       = default(MimeStringList);
            AddressParserResult addressParserResult  = this.parser.ParseNextMailbox(ref displayNameFragments, ref mimeStringList);

            switch (addressParserResult)
            {
            case AddressParserResult.Mailbox:
            case AddressParserResult.GroupInProgress:
            {
                MimeRecipient mimeRecipient = new MimeRecipient(ref mimeStringList, ref displayNameFragments);
                if (this.staticParsing)
                {
                    MimeRecipient.ConvertDisplayNameBack(mimeRecipient, displayNameFragments, headerDecodingOptions.AllowUTF8);
                }
                if (addressParserResult == AddressParserResult.GroupInProgress)
                {
                    MimeGroup mimeGroup = base.InternalLastChild as MimeGroup;
                    mimeGroup.InternalInsertAfter(mimeRecipient, mimeGroup.InternalLastChild);
                    return(mimeRecipient);
                }
                base.InternalInsertAfter(mimeRecipient, base.InternalLastChild);
                if (!fromGroup)
                {
                    return(mimeRecipient);
                }
                return(null);
            }

            case AddressParserResult.GroupStart:
            {
                MimeGroup mimeGroup = new MimeGroup(ref displayNameFragments);
                if (this.staticParsing)
                {
                    MimeRecipient.ConvertDisplayNameBack(mimeGroup, displayNameFragments, headerDecodingOptions.AllowUTF8);
                }
                base.InternalInsertAfter(mimeGroup, base.InternalLastChild);
                return(mimeGroup);
            }

            case AddressParserResult.End:
                return(null);

            default:
                return(null);
            }
        }