Esempio n. 1
0
        object IAddressProvider.ParseXElement(XElement element)
        {
            string address     = element.Value;
            string receiptType = element.TryGetAttributeValue("Type", MailingEntryObject.ReceiptType.To.ToString());

            return(MailingEntryObject.FromAddress(address, receiptType));
        }
        /// <summary>
        /// Parses a specified address and recipient type into a <see cref="MailingEntryObject"/>-instance.
        /// </summary>
        /// <param name="address">The e-mail address to parse.</param>
        /// <param name="receiptType">The receipt type.</param>
        /// <returns></returns>
        public static MailingEntryObject FromAddress(string address, string receiptType)
        {
            MailingEntryObject returnValue = new MailingEntryObject();
            returnValue.Address = TryParseMailAddress(address);
            if (returnValue.Address == null)
            {
                return null;
            }

            ReceiptType receiptTypeEnum = ReceiptType.To;
            if (!Enum.TryParse<ReceiptType>(receiptType, true, out receiptTypeEnum))
            {
                return null;
            }

            returnValue.Type = receiptTypeEnum;

            return returnValue;
        }
        internal static MailingEntryObject FromAddress(string address, string receiptType)
        {
            MailingEntryObject returnValue = new MailingEntryObject();

            returnValue.Address = TryParseMailAddress(address);
            if (returnValue.Address == null)
            {
                return(null);
            }

            ReceiptType receiptTypeEnum = ReceiptType.To;

            if (!Enum.TryParse <ReceiptType>(receiptType, true, out receiptTypeEnum))
            {
                return(null);
            }

            returnValue.Type = receiptTypeEnum;

            return(returnValue);
        }