Пример #1
0
        public virtual void WriteTo(XElement xE)
        {
            XElement xItem = null;

            if (AdGroupId != null)
            {
                xItem = new XElement(XName.Get("adGroupId", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(AdGroupId.Value.ToString());
                xE.Add(xItem);
            }
            if (Ad != null)
            {
                xItem = new XElement(XName.Get("ad", "https://adwords.google.com/api/adwords/cm/v201609"));
                Ad.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (Status != null)
            {
                xItem = new XElement(XName.Get("status", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(Status.Value.ToXmlValue());
                xE.Add(xItem);
            }
            if (ApprovalStatus != null)
            {
                xItem = new XElement(XName.Get("approvalStatus", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(ApprovalStatus.Value.ToXmlValue());
                xE.Add(xItem);
            }
            if (Trademarks != null)
            {
                foreach (var trademarksItem in Trademarks)
                {
                    xItem = new XElement(XName.Get("trademarks", "https://adwords.google.com/api/adwords/cm/v201609"));
                    xItem.Add(trademarksItem);
                    xE.Add(xItem);
                }
            }
            if (DisapprovalReasons != null)
            {
                foreach (var disapprovalReasonsItem in DisapprovalReasons)
                {
                    xItem = new XElement(XName.Get("disapprovalReasons", "https://adwords.google.com/api/adwords/cm/v201609"));
                    xItem.Add(disapprovalReasonsItem);
                    xE.Add(xItem);
                }
            }
            if (TrademarkDisapproved != null)
            {
                xItem = new XElement(XName.Get("trademarkDisapproved", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(TrademarkDisapproved.Value.ToString());
                xE.Add(xItem);
            }
            if (Labels != null)
            {
                foreach (var labelsItem in Labels)
                {
                    xItem = new XElement(XName.Get("labels", "https://adwords.google.com/api/adwords/cm/v201609"));
                    labelsItem.WriteTo(xItem);
                    xE.Add(xItem);
                }
            }
            if (BaseCampaignId != null)
            {
                xItem = new XElement(XName.Get("baseCampaignId", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(BaseCampaignId.Value.ToString());
                xE.Add(xItem);
            }
            if (BaseAdGroupId != null)
            {
                xItem = new XElement(XName.Get("baseAdGroupId", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(BaseAdGroupId.Value.ToString());
                xE.Add(xItem);
            }
            if (ForwardCompatibilityMap != null)
            {
                foreach (var forwardCompatibilityMapItem in ForwardCompatibilityMap)
                {
                    xItem = new XElement(XName.Get("forwardCompatibilityMap", "https://adwords.google.com/api/adwords/cm/v201609"));
                    forwardCompatibilityMapItem.WriteTo(xItem);
                    xE.Add(xItem);
                }
            }
        }
Пример #2
0
 public virtual void ReadFrom(XElement xE)
 {
     AdGroupId               = null;
     Ad                      = null;
     Status                  = null;
     ApprovalStatus          = null;
     Trademarks              = null;
     DisapprovalReasons      = null;
     TrademarkDisapproved    = null;
     Labels                  = null;
     BaseCampaignId          = null;
     BaseAdGroupId           = null;
     ForwardCompatibilityMap = null;
     foreach (var xItem in xE.Elements())
     {
         var localName = xItem.Name.LocalName;
         if (localName == "adGroupId")
         {
             AdGroupId = long.Parse(xItem.Value);
         }
         else if (localName == "ad")
         {
             Ad = InstanceCreator.CreateAd(xItem);
             Ad.ReadFrom(xItem);
         }
         else if (localName == "status")
         {
             Status = AdGroupAdStatusExtensions.Parse(xItem.Value);
         }
         else if (localName == "approvalStatus")
         {
             ApprovalStatus = AdGroupAdApprovalStatusExtensions.Parse(xItem.Value);
         }
         else if (localName == "trademarks")
         {
             if (Trademarks == null)
             {
                 Trademarks = new List <string>();
             }
             Trademarks.Add(xItem.Value);
         }
         else if (localName == "disapprovalReasons")
         {
             if (DisapprovalReasons == null)
             {
                 DisapprovalReasons = new List <string>();
             }
             DisapprovalReasons.Add(xItem.Value);
         }
         else if (localName == "trademarkDisapproved")
         {
             TrademarkDisapproved = bool.Parse(xItem.Value);
         }
         else if (localName == "labels")
         {
             if (Labels == null)
             {
                 Labels = new List <Label>();
             }
             var labelsItem = InstanceCreator.CreateLabel(xItem);
             labelsItem.ReadFrom(xItem);
             Labels.Add(labelsItem);
         }
         else if (localName == "baseCampaignId")
         {
             BaseCampaignId = long.Parse(xItem.Value);
         }
         else if (localName == "baseAdGroupId")
         {
             BaseAdGroupId = long.Parse(xItem.Value);
         }
         else if (localName == "forwardCompatibilityMap")
         {
             if (ForwardCompatibilityMap == null)
             {
                 ForwardCompatibilityMap = new List <String_StringMapEntry>();
             }
             var forwardCompatibilityMapItem = new String_StringMapEntry();
             forwardCompatibilityMapItem.ReadFrom(xItem);
             ForwardCompatibilityMap.Add(forwardCompatibilityMapItem);
         }
     }
 }