Example #1
0
        internal static void Write(XmlWriter writer, Phone phone)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (phone == null)
            {
                throw new ArgumentNullException("phone");
            }

            writer.WriteStartElement(PhoneSerializer.Phone);
            SerializationHelper.WriteElementStringNotNull(writer, PhoneSerializer.AreaCode, phone.AreaCode);
            SerializationHelper.WriteElementStringNotNull(writer, PhoneSerializer.Number, phone.Number);
            writer.WriteEndElement();
        }
        internal static void Write(XmlWriter writer, PaymentRequest payment)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (payment == null)
            {
                throw new ArgumentNullException("payment");
            }

            writer.WriteStartElement(PaymentRequestSerializer.Checkout);

            writer.WriteElementString(PaymentRequestSerializer.Currency, payment.Currency);

            if (payment.Sender != null)
            {
                SenderSerializer.Write(writer, payment.Sender);
            }

            if (payment.RedirectUri != null)
            {
                writer.WriteElementString(PaymentRequestSerializer.RedirectUrl, payment.RedirectUri.ToString());
            }

            if (payment.Items.Count > 0)
            {
                ItemListSerializer.Write(writer, payment.Items);
            }

            SerializationHelper.WriteElementStringNotNull(writer, PaymentRequestSerializer.ExtraAmount, payment.ExtraAmount);
            SerializationHelper.WriteElementStringNotNull(writer, PaymentRequestSerializer.Reference, payment.Reference);

            if (payment.Shipping != null)
            {
                ShippingSerializer.Write(writer, payment.Shipping);
            }

            SerializationHelper.WriteElementStringNotNull(writer, PaymentRequestSerializer.MaxAge, payment.MaxAge);
            SerializationHelper.WriteElementStringNotNull(writer, PaymentRequestSerializer.MaxUses, payment.MaxUses);

            writer.WriteEndElement();
        }
Example #3
0
        internal static void Write(XmlWriter writer, Item item)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            writer.WriteStartElement(ItemSerializer.Item);
            writer.WriteElementString(ItemSerializer.Id, item.Id);
            writer.WriteElementString(ItemSerializer.Description, item.Description);
            SerializationHelper.WriteElementString(writer, ItemSerializer.Quantity, item.Quantity);
            SerializationHelper.WriteElementString(writer, ItemSerializer.Amount, item.Amount);
            SerializationHelper.WriteElementStringNotNull(writer, ItemSerializer.Weight, item.Weight);
            SerializationHelper.WriteElementStringNotNull(writer, ItemSerializer.ShippingCost, item.ShippingCost);
            writer.WriteEndElement();
        }
        internal static void Write(XmlWriter writer, Sender sender)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }

            writer.WriteStartElement(SenderSerializer.Sender);

            SerializationHelper.WriteElementStringNotNull(writer, SenderSerializer.Name, sender.Name);
            SerializationHelper.WriteElementStringNotNull(writer, SenderSerializer.Email, sender.Email);

            if (sender.Phone != null)
            {
                PhoneSerializer.Write(writer, sender.Phone);
            }
            writer.WriteEndElement();
        }
        internal static void Write(XmlWriter writer, Shipping shipping)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (shipping == null)
            {
                throw new ArgumentNullException("shipping");
            }

            writer.WriteStartElement(ShippingSerializer.Shipping);

            SerializationHelper.WriteElementStringNotNull(writer, ShippingSerializer.ShippingType, shipping.ShippingType);
            SerializationHelper.WriteElementStringNotNull(writer, ShippingSerializer.Cost, shipping.Cost);

            if (shipping.Address != null)
            {
                AddressSerializer.Write(writer, shipping.Address);
            }

            writer.WriteEndElement();
        }
        internal static void Write(XmlWriter writer, Address address)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            writer.WriteStartElement(AddressSerializer.Address);

            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.Country, address.Country);
            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.State, address.State);
            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.City, address.City);
            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.District, address.District);
            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.PostalCode, address.PostalCode);
            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.Street, address.Street);
            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.Number, address.Number);
            SerializationHelper.WriteElementStringNotNull(writer, AddressSerializer.Complement, address.Complement);

            writer.WriteEndElement();
        }