/// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="preApproval"></param>
        internal static void Read(XmlReader reader, PreApprovalSummary preApproval)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SerializerHelper.PreApproval);

            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.PreApproval))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Code:
                        preApproval.Code = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Date:
                        preApproval.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Reference:
                        preApproval.Reference = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.TransactionStatus:
                        preApproval.Status = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.LastEventDate:
                        preApproval.LastEventDate = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Name:
                        preApproval.Name = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Tracker:
                        preApproval.Tracker = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Charge:
                        preApproval.Charge = reader.ReadElementContentAsString();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        /// Converts xml into a Address class
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="address"></param>
        internal static void Read(XmlReader reader, Address address)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(AddressSerializer.Address);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, AddressSerializer.Address))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case AddressSerializer.Country:
                        address.Country = reader.ReadElementContentAsString();
                        break;

                    case AddressSerializer.State:
                        address.State = reader.ReadElementContentAsString();
                        break;

                    case AddressSerializer.City:
                        address.City = reader.ReadElementContentAsString();
                        break;

                    case AddressSerializer.District:
                        address.District = reader.ReadElementContentAsString();
                        break;

                    case AddressSerializer.PostalCode:
                        address.PostalCode = reader.ReadElementContentAsString();
                        break;

                    case AddressSerializer.Street:
                        address.Street = reader.ReadElementContentAsString();
                        break;

                    case AddressSerializer.Number:
                        address.Number = reader.ReadElementContentAsString();
                        break;

                    case AddressSerializer.Complement:
                        address.Complement = reader.ReadElementContentAsString();
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transaction"></param>
        /// <param name="payment"></param>
        internal static void Read(XmlReader reader, Transaction transaction, bool payment = true)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement();
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.PreApproval))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Code:
                        transaction.Code = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Date:
                        transaction.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Reference:
                        transaction.Reference = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.TransactionType:
                        transaction.TransactionType = reader.ReadElementContentAsInt();
                        break;

                    case SerializerHelper.TransactionStatus:
                        transaction.TransactionStatus = reader.ReadElementContentAsInt();
                        break;

                    case SerializerHelper.PaymentLink:
                        transaction.PaymentLink = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.GrossAmount:
                        transaction.GrossAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.DiscountAmount:
                        transaction.DiscountAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.CreditorFees:
                        CreditorFees creditorFees = new CreditorFees();
                        CreditorFeesSerializer.Read(reader, creditorFees);
                        transaction.CreditorFees = creditorFees;
                        break;

                    case SerializerHelper.FeeAmount:
                        transaction.FeeAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.NetAmount:
                        transaction.NetAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.ExtraAmount:
                        transaction.ExtraAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.LastEventDate:
                        transaction.LastEventDate = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.InstallmentCount:
                        transaction.InstallmentCount = reader.ReadElementContentAsInt();
                        break;

                    case PaymentMethodSerializer.PaymentMethod:
                        PaymentMethod paymentMethod = new PaymentMethod();
                        PaymentMethodSerializer.Read(reader, paymentMethod);
                        transaction.PaymentMethod = paymentMethod;
                        break;

                    case ItemListSerializer.Items:
                        ItemListSerializer.Read(reader, transaction.Items);
                        break;

                    case SenderSerializer.Sender:
                        Sender sender = new Sender();
                        SenderSerializer.Read(reader, sender);
                        transaction.Sender = sender;
                        break;

                    case ShippingSerializer.Shipping:
                        Shipping shipping = new Shipping();
                        ShippingSerializer.Read(reader, shipping);
                        transaction.Shipping = shipping;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transactions"></param>
        /// /// <param name="preApproval"></param>
        internal static void Read(XmlReader reader, IList <TransactionSummary> transactions, bool preApproval)
        {
            transactions.Clear();

            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
            }

            if (preApproval == true)
            {
                reader.ReadStartElement(TransactionSummaryListSerializer.PreApprovals);
            }
            else
            {
                reader.ReadStartElement(TransactionSummaryListSerializer.Transactions);
            }
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (preApproval == true)
                {
                    if (XMLParserUtils.IsEndElement(reader, TransactionSummaryListSerializer.PreApprovals))
                    {
                        XMLParserUtils.SkipNode(reader);
                        break;
                    }
                }
                else
                {
                    if (XMLParserUtils.IsEndElement(reader, TransactionSummaryListSerializer.Transactions))
                    {
                        XMLParserUtils.SkipNode(reader);
                        break;
                    }
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    TransactionSummary transaction = new TransactionSummary();
                    switch (reader.Name)
                    {
                    case TransactionSerializerHelper.Transaction:
                        TransactionSummarySerializer.Read(reader, transaction, preApproval);
                        transactions.Add(transaction);
                        break;

                    case TransactionSerializerHelper.PreApproval:
                        TransactionSummarySerializer.Read(reader, transaction, preApproval);
                        transactions.Add(transaction);
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transaction"></param>
        internal static void Read(XmlReader reader, TransactionSummary transaction)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            reader.ReadStartElement(SerializerHelper.Transaction);
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (XMLParserUtils.IsEndElement(reader, SerializerHelper.Transaction))
                {
                    XMLParserUtils.SkipNode(reader);
                    break;
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case SerializerHelper.Code:
                        transaction.Code = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.Date:
                        transaction.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case SerializerHelper.Reference:
                        transaction.Reference = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.TransactionType:
                        transaction.TransactionType = reader.ReadElementContentAsInt();
                        break;

                    case SerializerHelper.TransactionStatus:
                        transaction.TransactionStatus = reader.ReadElementContentAsInt();
                        break;

                    case SerializerHelper.PaymentLink:
                        transaction.PaymentLink = reader.ReadElementContentAsString();
                        break;

                    case SerializerHelper.GrossAmount:
                        transaction.GrossAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.DiscountAmount:
                        transaction.DiscountAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.FeeAmount:
                        transaction.FeeAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.NetAmount:
                        transaction.NetAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.ExtraAmount:
                        transaction.ExtraAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case SerializerHelper.LastEventDate:
                        transaction.LastEventDate = reader.ReadElementContentAsDateTime();
                        break;

                    case PaymentMethodSerializer.PaymentMethod:
                        PaymentMethod paymentMethod = new PaymentMethod();
                        PaymentMethodSerializer.Read(reader, paymentMethod);
                        transaction.PaymentMethod = paymentMethod;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        throw new InvalidOperationException("Unexpected value");
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transaction"></param>
        internal static void Read(XmlReader reader, TransactionSummary transaction, bool preApproval)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            if (preApproval == true)
            {
                reader.ReadStartElement(TransactionSerializerHelper.PreApproval);
            }
            else
            {
                reader.ReadStartElement(TransactionSerializerHelper.Transaction);
            }
            reader.MoveToContent();

            while (!reader.EOF)
            {
                if (preApproval == true)
                {
                    if (XMLParserUtils.IsEndElement(reader, TransactionSerializerHelper.PreApproval))
                    {
                        XMLParserUtils.SkipNode(reader);
                        break;
                    }
                }
                else
                {
                    if (XMLParserUtils.IsEndElement(reader, TransactionSerializerHelper.Transaction))
                    {
                        XMLParserUtils.SkipNode(reader);
                        break;
                    }
                }

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                    case TransactionSerializerHelper.Code:
                        transaction.Code = reader.ReadElementContentAsString();
                        break;

                    case TransactionSerializerHelper.Date:
                        transaction.Date = reader.ReadElementContentAsDateTime();
                        break;

                    case TransactionSerializerHelper.Reference:
                        transaction.Reference = reader.ReadElementContentAsString();
                        break;

                    case TransactionSerializerHelper.TransactionType:
                        transaction.TransactionType = reader.ReadElementContentAsInt();
                        break;

                    case TransactionSerializerHelper.TransactionStatus:
                        if (preApproval == true)
                        {
                            transaction.Status = reader.ReadElementContentAsString();
                        }
                        else
                        {
                            transaction.TransactionStatus = reader.ReadElementContentAsInt();
                        }
                        break;

                    case TransactionSerializerHelper.GrossAmount:
                        transaction.GrossAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.DiscountAmount:
                        transaction.DiscountAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.FeeAmount:
                        transaction.FeeAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.NetAmount:
                        transaction.NetAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.ExtraAmount:
                        transaction.ExtraAmount = reader.ReadElementContentAsDecimal();
                        break;

                    case TransactionSerializerHelper.LastEventDate:
                        transaction.LastEventDate = reader.ReadElementContentAsDateTime();
                        break;

                    case TransactionSerializerHelper.Name:
                        transaction.Name = reader.ReadElementContentAsString();
                        break;

                    case TransactionSerializerHelper.Tracker:
                        transaction.Tracker = reader.ReadElementContentAsString();
                        break;

                    case TransactionSerializerHelper.Charge:
                        transaction.Charge = reader.ReadElementContentAsString();
                        break;

                    case PaymentMethodSerializer.PaymentMethod:
                        PaymentMethod paymentMethod = new PaymentMethod();
                        PaymentMethodSerializer.Read(reader, paymentMethod);
                        transaction.PaymentMethod = paymentMethod;
                        break;

                    default:
                        XMLParserUtils.SkipElement(reader);
                        break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }