Exemplo n.º 1
0
 public virtual void ReadFrom(XElement xE)
 {
     Id                    = null;
     Status                = null;
     ProgressStats         = null;
     UploadUrl             = null;
     DownloadUrl           = null;
     ProcessingErrors      = null;
     DiskUsageQuotaBalance = null;
     foreach (var xItem in xE.Elements())
     {
         var localName = xItem.Name.LocalName;
         if (localName == "id")
         {
             Id = long.Parse(xItem.Value);
         }
         else if (localName == "status")
         {
             Status = BatchJobStatusExtensions.Parse(xItem.Value);
         }
         else if (localName == "progressStats")
         {
             ProgressStats = new ProgressStats();
             ProgressStats.ReadFrom(xItem);
         }
         else if (localName == "uploadUrl")
         {
             UploadUrl = new TemporaryUrl();
             UploadUrl.ReadFrom(xItem);
         }
         else if (localName == "downloadUrl")
         {
             DownloadUrl = new TemporaryUrl();
             DownloadUrl.ReadFrom(xItem);
         }
         else if (localName == "processingErrors")
         {
             if (ProcessingErrors == null)
             {
                 ProcessingErrors = new List <BatchJobProcessingError>();
             }
             var processingErrorsItem = new BatchJobProcessingError();
             processingErrorsItem.ReadFrom(xItem);
             ProcessingErrors.Add(processingErrorsItem);
         }
         else if (localName == "diskUsageQuotaBalance")
         {
             DiskUsageQuotaBalance = long.Parse(xItem.Value);
         }
     }
 }
Exemplo n.º 2
0
        public virtual void WriteTo(XElement xE)
        {
            XElement xItem = null;

            if (Id != null)
            {
                xItem = new XElement(XName.Get("id", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(Id.Value.ToString());
                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 (ProgressStats != null)
            {
                xItem = new XElement(XName.Get("progressStats", "https://adwords.google.com/api/adwords/cm/v201609"));
                ProgressStats.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (UploadUrl != null)
            {
                xItem = new XElement(XName.Get("uploadUrl", "https://adwords.google.com/api/adwords/cm/v201609"));
                UploadUrl.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (DownloadUrl != null)
            {
                xItem = new XElement(XName.Get("downloadUrl", "https://adwords.google.com/api/adwords/cm/v201609"));
                DownloadUrl.WriteTo(xItem);
                xE.Add(xItem);
            }
            if (ProcessingErrors != null)
            {
                foreach (var processingErrorsItem in ProcessingErrors)
                {
                    xItem = new XElement(XName.Get("processingErrors", "https://adwords.google.com/api/adwords/cm/v201609"));
                    processingErrorsItem.WriteTo(xItem);
                    xE.Add(xItem);
                }
            }
            if (DiskUsageQuotaBalance != null)
            {
                xItem = new XElement(XName.Get("diskUsageQuotaBalance", "https://adwords.google.com/api/adwords/cm/v201609"));
                xItem.Add(DiskUsageQuotaBalance.Value.ToString());
                xE.Add(xItem);
            }
        }