示例#1
0
        internal override void ReadXml(XmlTextReader reader)
        {
            UnitAmountInCents.Clear();
            SetupFeeInCents.Clear();

            while (reader.Read())
            {
                // End of account element, get out of here
                if (reader.Name == "plan" && reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }

                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                switch (reader.Name)
                {
                case "plan_code":
                    PlanCode = reader.ReadElementContentAsString();
                    break;

                case "name":
                    Name = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "success_url":
                    SuccessUrl = reader.ReadElementContentAsString();
                    break;

                case "cancel_url":
                    CancelUrl = reader.ReadElementContentAsString();
                    break;

                case "display_donation_amounts":
                    DisplayDonationAmounts = reader.ReadElementContentAsBoolean();
                    break;

                case "display_quantity":
                    DisplayQuantity = reader.ReadElementContentAsBoolean();
                    break;

                case "display_phone_number":
                    DisplayPhoneNumber = reader.ReadElementContentAsBoolean();
                    break;

                case "bypass_hosted_confirmation":
                    BypassHostedConfirmation = reader.ReadElementContentAsBoolean();
                    break;

                case "unit_name":
                    UnitName = reader.ReadElementContentAsString();
                    break;

                case "payment_page_tos_link":
                    PaymentPageTOSLink = reader.ReadElementContentAsString();
                    break;

                case "plan_interval_length":
                    PlanIntervalLength = reader.ReadElementContentAsInt();
                    break;

                case "plan_interval_unit":
                    PlanIntervalUnit = reader.ReadElementContentAsString().ParseAsEnum <IntervalUnit>();
                    break;

                case "trial_interval_length":
                    TrialIntervalLength = reader.ReadElementContentAsInt();
                    break;

                case "trial_interval_unit":
                    TrialIntervalUnit = reader.ReadElementContentAsString().ParseAsEnum <IntervalUnit>();
                    break;

                case "accounting_code":
                    AccountingCode = reader.ReadElementContentAsString();
                    break;

                case "created_at":
                    CreatedAt = reader.ReadElementContentAsDateTime();
                    break;

                case "tax_exempt":
                    TaxExempt = reader.ReadElementContentAsBoolean();
                    break;

                case "tax_code":
                    TaxCode = reader.ReadElementContentAsString();
                    break;

                case "unit_amount_in_cents":
                    ReadXmlUnitAmount(reader);
                    break;

                case "setup_fee_in_cents":
                    ReadXmlSetupFee(reader);
                    break;
                }
            }
        }
示例#2
0
        internal override void ReadXml(XmlTextReader reader)
        {
            UnitAmountInCents.Clear();
            SetupFeeInCents.Clear();

            while (reader.Read())
            {
                // End of account element, get out of here
                if (reader.Name == "plan" && reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }

                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                bool b;

                switch (reader.Name)
                {
                case "plan_code":
                    PlanCode = reader.ReadElementContentAsString();
                    break;

                case "name":
                    Name = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "success_url":
                    SuccessUrl = reader.ReadElementContentAsString();
                    break;

                case "cancel_url":
                    CancelUrl = reader.ReadElementContentAsString();
                    break;

                case "display_donation_amounts":
                    DisplayDonationAmounts = reader.ReadElementContentAsBoolean();
                    break;

                case "display_quantity":
                    DisplayQuantity = reader.ReadElementContentAsBoolean();
                    break;

                case "display_phone_number":
                    DisplayPhoneNumber = reader.ReadElementContentAsBoolean();
                    break;

                case "bypass_hosted_confirmation":
                    BypassHostedConfirmation = reader.ReadElementContentAsBoolean();
                    break;

                case "unit_name":
                    UnitName = reader.ReadElementContentAsString();
                    break;

                case "payment_page_tos_link":
                    PaymentPageTOSLink = reader.ReadElementContentAsString();
                    break;

                case "plan_interval_length":
                    PlanIntervalLength = reader.ReadElementContentAsInt();
                    break;

                case "plan_interval_unit":
                    PlanIntervalUnit = reader.ReadElementContentAsString().ParseAsEnum <IntervalUnit>();
                    break;

                case "trial_interval_length":
                    TrialIntervalLength = reader.ReadElementContentAsInt();
                    break;

                case "trial_interval_unit":
                    TrialIntervalUnit = reader.ReadElementContentAsString().ParseAsEnum <IntervalUnit>();
                    break;

                case "accounting_code":
                    AccountingCode = reader.ReadElementContentAsString();
                    break;

                case "setup_fee_accounting_code":
                    SetupFeeAccountingCode = reader.ReadElementContentAsString();
                    break;

                case "created_at":
                    CreatedAt = reader.ReadElementContentAsDateTime();
                    break;

                case "updated_at":
                    UpdatedAt = reader.ReadElementContentAsDateTime();
                    break;

                case "tax_exempt":
                    TaxExempt = reader.ReadElementContentAsBoolean();
                    break;

                case "tax_code":
                    TaxCode = reader.ReadElementContentAsString();
                    break;

                case "unit_amount_in_cents":
                    ReadXmlUnitAmount(reader);
                    break;

                case "setup_fee_in_cents":
                    ReadXmlSetupFee(reader);
                    break;

                case "total_billing_cycles":
                    int totalBillingCycles;
                    if (int.TryParse(reader.ReadElementContentAsString(), out totalBillingCycles))
                    {
                        TotalBillingCycles = totalBillingCycles;
                    }
                    break;

                case "trial_requires_billing_info":
                    if (bool.TryParse(reader.ReadElementContentAsString(), out b))
                    {
                        TrialRequiresBillingInfo = b;
                    }
                    break;

                case "revenue_schedule_type":
                    var revenueScheduleType = reader.ReadElementContentAsString();
                    if (!revenueScheduleType.IsNullOrEmpty())
                    {
                        RevenueScheduleType = revenueScheduleType.ParseAsEnum <Adjustment.RevenueSchedule>();
                    }
                    break;

                case "setup_fee_revenue_schedule_type":
                    var setupFeeRevenueScheduleType = reader.ReadElementContentAsString();
                    if (!setupFeeRevenueScheduleType.IsNullOrEmpty())
                    {
                        SetupFeeRevenueScheduleType = setupFeeRevenueScheduleType.ParseAsEnum <Adjustment.RevenueSchedule>();
                    }
                    break;

                case "auto_renew":
                    if (bool.TryParse(reader.ReadElementContentAsString(), out b))
                    {
                        AutoRenew = b;
                    }
                    break;
                }
            }
        }