/// <summary> /// /// </summary> /// <param name="reader"></param> /// <param name="transaction"></param> internal static void Read(XmlReader reader, PreApprovalTransaction 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; case ItemListSerializer.Items: ItemListSerializer.Read(reader, preApproval.Items); break; default: XMLParserUtils.SkipElement(reader); break; } } else { XMLParserUtils.SkipNode(reader); } } }
/// <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); break; } } else { XMLParserUtils.SkipNode(reader); } } }