コード例 #1
0
ファイル: ShippingSerializer.cs プロジェクト: Japle/dotnet
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="shipping"></param>
        internal static void Read(XmlReader reader, Shipping shipping)
        {

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

            reader.ReadStartElement(ShippingSerializer.Shipping);
            reader.MoveToContent();

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

                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case ShippingSerializer.ShippingType:
                            shipping.ShippingType = reader.ReadElementContentAsInt();
                            break;
                        case ShippingSerializer.Cost:
                            shipping.Cost = reader.ReadElementContentAsDecimal();
                            break;
                        case AddressSerializer.Address:
                            Address address = new Address();
                            AddressSerializer.Read(reader, address);
                            shipping.Address = address;
                            break;
                        default:
                            XMLParserUtils.SkipElement(reader);
                            break;
                    }
                }
                else
                {
                    XMLParserUtils.SkipNode(reader);
                }
            }
        }
コード例 #2
0
ファイル: TransactionSerializer.cs プロジェクト: Japle/dotnet
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="transaction"></param>
        internal static void Read(XmlReader reader, Transaction 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.InstallmentCount:
                            transaction.InstallmentCount = reader.ReadElementContentAsInt();
                            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;
                        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);
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Japle/dotnet
        static void ShippingExample()
        {
            PaymentRequest paymentRequest = new PaymentRequest();

            Shipping shipping = new Shipping();
            shipping.ShippingType = ShippingType.Pac;
            shipping.Address =
                new Address(
                    "BRA",
                    "SP",
                    "São Paulo",
                    "Jardim Paulistano",
                    "01452002",
                    "Av. Brig. Faria Lima",
                    "1384",
                    "5o. Andar");

            paymentRequest.Shipping = shipping;
        }