Ejemplo n.º 1
0
        public virtual void WriteTo(XElement xE)
        {
            XElement xItem = null;

            if (Bid != null)
            {
                xItem = new XElement(XName.Get("bid", "https://adwords.google.com/api/adwords/cm/v201609"));
                Bid.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (Clicks != null)
            {
                xItem = new XElement(XName.Get("clicks", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(Clicks.Value.ToString());
                xE.Add(xItem);
            }
            if (Cost != null)
            {
                xItem = new XElement(XName.Get("cost", "https://adwords.google.com/api/adwords/cm/v201609"));
                Cost.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (Impressions != null)
            {
                xItem = new XElement(XName.Get("impressions", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(Impressions.Value.ToString());
                xE.Add(xItem);
            }
            if (PromotedImpressions != null)
            {
                xItem = new XElement(XName.Get("promotedImpressions", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(PromotedImpressions.Value.ToString());
                xE.Add(xItem);
            }
            if (RequiredBudget != null)
            {
                xItem = new XElement(XName.Get("requiredBudget", "https://adwords.google.com/api/adwords/cm/v201609"));
                RequiredBudget.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (BidModifier != null)
            {
                xItem = new XElement(XName.Get("bidModifier", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(BidModifier.Value.ToString());
                xE.Add(xItem);
            }
            if (TotalLocalImpressions != null)
            {
                xItem = new XElement(XName.Get("totalLocalImpressions", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(TotalLocalImpressions.Value.ToString());
                xE.Add(xItem);
            }
            if (TotalLocalClicks != null)
            {
                xItem = new XElement(XName.Get("totalLocalClicks", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(TotalLocalClicks.Value.ToString());
                xE.Add(xItem);
            }
            if (TotalLocalCost != null)
            {
                xItem = new XElement(XName.Get("totalLocalCost", "https://adwords.google.com/api/adwords/cm/v201609"));
                TotalLocalCost.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (TotalLocalPromotedImpressions != null)
            {
                xItem = new XElement(XName.Get("totalLocalPromotedImpressions", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(TotalLocalPromotedImpressions.Value.ToString());
                xE.Add(xItem);
            }
        }
Ejemplo n.º 2
0
 public override void ReadFrom(XElement xE)
 {
     base.ReadFrom(xE);
     UserStatus                   = null;
     SystemServingStatus          = null;
     ApprovalStatus               = null;
     DisapprovalReasons           = null;
     DestinationUrl               = null;
     FirstPageCpc                 = null;
     TopOfPageCpc                 = null;
     FirstPositionCpc             = null;
     QualityInfo                  = null;
     BiddingStrategyConfiguration = null;
     BidModifier                  = null;
     FinalUrls           = null;
     FinalMobileUrls     = null;
     FinalAppUrls        = null;
     TrackingUrlTemplate = null;
     UrlCustomParameters = null;
     foreach (var xItem in xE.Elements())
     {
         var localName = xItem.Name.LocalName;
         if (localName == "userStatus")
         {
             UserStatus = UserStatusExtensions.Parse(xItem.Value);
         }
         else if (localName == "systemServingStatus")
         {
             SystemServingStatus = SystemServingStatusExtensions.Parse(xItem.Value);
         }
         else if (localName == "approvalStatus")
         {
             ApprovalStatus = ApprovalStatusExtensions.Parse(xItem.Value);
         }
         else if (localName == "disapprovalReasons")
         {
             if (DisapprovalReasons == null)
             {
                 DisapprovalReasons = new List <string>();
             }
             DisapprovalReasons.Add(xItem.Value);
         }
         else if (localName == "destinationUrl")
         {
             DestinationUrl = xItem.Value;
         }
         else if (localName == "firstPageCpc")
         {
             FirstPageCpc = new Bid();
             FirstPageCpc.ReadFrom(xItem);
         }
         else if (localName == "topOfPageCpc")
         {
             TopOfPageCpc = new Bid();
             TopOfPageCpc.ReadFrom(xItem);
         }
         else if (localName == "firstPositionCpc")
         {
             FirstPositionCpc = new Bid();
             FirstPositionCpc.ReadFrom(xItem);
         }
         else if (localName == "qualityInfo")
         {
             QualityInfo = new QualityInfo();
             QualityInfo.ReadFrom(xItem);
         }
         else if (localName == "biddingStrategyConfiguration")
         {
             BiddingStrategyConfiguration = new BiddingStrategyConfiguration();
             BiddingStrategyConfiguration.ReadFrom(xItem);
         }
         else if (localName == "bidModifier")
         {
             BidModifier = double.Parse(xItem.Value);
         }
         else if (localName == "finalUrls")
         {
             FinalUrls = new UrlList();
             FinalUrls.ReadFrom(xItem);
         }
         else if (localName == "finalMobileUrls")
         {
             FinalMobileUrls = new UrlList();
             FinalMobileUrls.ReadFrom(xItem);
         }
         else if (localName == "finalAppUrls")
         {
             FinalAppUrls = new AppUrlList();
             FinalAppUrls.ReadFrom(xItem);
         }
         else if (localName == "trackingUrlTemplate")
         {
             TrackingUrlTemplate = xItem.Value;
         }
         else if (localName == "urlCustomParameters")
         {
             UrlCustomParameters = new CustomParameters();
             UrlCustomParameters.ReadFrom(xItem);
         }
     }
 }