Litle.Sdk.subscription.Serialize C# (CSharp) Method

Serialize() public method

public Serialize ( ) : string
return string
        public string Serialize()
        {
            string xml = "";
            xml += "\r\n<planCode>" + planCode + "</planCode>";
            if(numberOfPaymentsSet) xml += "\r\n<numberOfPayments>" + numberOfPayments + "</numberOfPayments>";
            if (startDateSet) xml += "\r\n<startDate>" + XmlUtil.toXsdDate(startDateField) + "</startDate>";
            if(amountSet) xml += "\r\n<amount>" + amountField + "</amount>";
            foreach(createDiscount createDiscount in createDiscounts)
            {
                xml += "\r\n<createDiscount>" + createDiscount.Serialize() + "\r\n</createDiscount>";
            }
            foreach (createAddOn createAddOn in createAddOns)
            {
                xml += "\r\n<createAddOn>" + createAddOn.Serialize() + "\r\n</createAddOn>";
            }

            return xml;
        }

Usage Example

コード例 #1
0
        public void TestSubscription_CanContainCreateDiscounts()
        {
            subscription subscription = new subscription();
            subscription.planCode = "123abc";

            createDiscount cd1 = new createDiscount();
            cd1.discountCode = "1";
            cd1.name = "cheaper";
            cd1.amount = 200;
            cd1.startDate = new DateTime(2013, 9, 5);
            cd1.endDate = new DateTime(2013, 9, 6);

            createDiscount cd2 = new createDiscount();
            cd2.discountCode = "2";
            cd2.name = "cheap";
            cd2.amount = 100;
            cd2.startDate = new DateTime(2013, 9, 3);
            cd2.endDate = new DateTime(2013, 9, 4);

            subscription.createDiscounts.Add(cd1);
            subscription.createDiscounts.Add(cd2);

            String actual = subscription.Serialize();
            String expected = @"
            <planCode>123abc</planCode>
            <createDiscount>
            <discountCode>1</discountCode>
            <name>cheaper</name>
            <amount>200</amount>
            <startDate>2013-09-05</startDate>
            <endDate>2013-09-06</endDate>
            </createDiscount>
            <createDiscount>
            <discountCode>2</discountCode>
            <name>cheap</name>
            <amount>100</amount>
            <startDate>2013-09-03</startDate>
            <endDate>2013-09-04</endDate>
            </createDiscount>";
            Assert.AreEqual(expected, actual);
        }
All Usage Examples Of Litle.Sdk.subscription::Serialize