internal void WriteXml(XmlTextWriter writer) { writer.WriteStartElement(ElementName); writer.WriteElementString(CouponCodeElement, CouponCode); writer.WriteElementString(NameElement,Name); writer.WriteElementStringIfProvided(HostedDescriptionElement,HostedDescription); writer.WriteElementStringIfProvided(InvoiceDescriptionElement, InvoiceDescription); writer.WriteElementDateTimeIfProvided(RedeemByDateElement, RedeemByDate); writer.WriteElementString(SingleUseElement, SingleUse.ToString()); writer.WriteElementIntIfProvided(AppliesForMonthsElement,AppliesForMonths); writer.WriteElementString(MaxRedemptionsElement, MaxRedemptions.ToString(CultureInfo.InvariantCulture)); WriteDiscountElements(writer); if(!AppliesToAllPlans) { writer.WriteElementString(AppliesToAllPlansElement, AppliesToAllPlans.ToString()); writer.WriteElementList(PlanCodeListElement, PlanCodes, WritePlanCodeItem); } writer.WriteEndElement(); }