protected override void EncodeEntry(Uri requestUrl, ListBlobsOperationContext lboc, IListBlobResultsBlobProperties blobProps, XmlWriter xmlWriter) { string str; string httpString; string eTag; if (!blobProps.IsActualBlob) { xmlWriter.WriteStartElement("BlobPrefix"); this.WriteElementString(xmlWriter, "Name", blobProps.BlobName); } else { xmlWriter.WriteStartElement("Blob"); this.WriteElementString(xmlWriter, "Name", blobProps.BlobName); if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue) { this.WriteElementString(xmlWriter, "Snapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(blobProps.Snapshot)); } if (lboc.ListingAcrossContainers) { NephosAssertionException.Assert(!string.IsNullOrEmpty(blobProps.ContainerName), string.Concat("XStore didn't return us valid ContainerName for this blob ", blobProps.BlobName, " when we are listing blobs across the account")); this.WriteElementString(xmlWriter, "ContainerName", blobProps.ContainerName); } if (lboc.IsIncludingUrlInResponse) { string empty = string.Empty; if (lboc.ListingAcrossContainers) { empty = string.Concat("/", blobProps.ContainerName); } string str1 = string.Concat(HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path)), empty); string str2 = HttpRequestAccessorCommon.TrimRootContainerNameFromEnd(str1, true); string str3 = string.Concat(str2, "/", blobProps.BlobName); if (lboc.IsIncludingSnapshots && blobProps.Snapshot != DateTime.MaxValue) { str3 = string.Concat(str3, HttpUtilities.GetSnapshotQueryParameterStringForUrl(blobProps.Snapshot)); } this.WriteElementString(xmlWriter, "Url", str3); } if (lboc.IsUsingPropertiesElement) { xmlWriter.WriteStartElement("Properties"); } string str4 = (lboc.IsUsingPropertiesElement ? "Last-Modified" : "LastModified"); string str5 = (lboc.IsUsingPropertiesElement ? "Content-Length" : "Size"); string str6 = (lboc.IsUsingPropertiesElement ? "Content-Type" : "ContentType"); string str7 = (lboc.IsUsingPropertiesElement ? "Content-Encoding" : "ContentEncoding"); string str8 = (lboc.IsUsingPropertiesElement ? "Content-Language" : "ContentLanguage"); string str9 = (lboc.IsUsingPropertiesElement ? "Cache-Control" : "CacheControl"); string str10 = (lboc.IsUsingPropertiesElement ? "Content-MD5" : "ContentMD5"); bool value = blobProps.LastModifiedTime.Value > DateTimeConstants.MinimumBlobLastModificationTime; if (value) { XmlWriter xmlWriter1 = xmlWriter; string str11 = str4; if (blobProps.LastModifiedTime.HasValue) { httpString = HttpUtilities.ConvertDateTimeToHttpString(blobProps.LastModifiedTime.Value); } else { httpString = null; } this.WriteElementString(xmlWriter1, str11, httpString); XmlWriter xmlWriter2 = xmlWriter; if (blobProps.LastModifiedTime.HasValue) { DateTime?lastModifiedTime = blobProps.LastModifiedTime; eTag = BasicHttpProcessor.GetETag(lastModifiedTime.Value, this.shouldEncloseEtagsInQuotes); } else { eTag = null; } this.WriteElementString(xmlWriter2, "Etag", eTag); } XmlWriter xmlWriter3 = xmlWriter; string str12 = str5; if (blobProps.ContentLength.HasValue) { str = blobProps.ContentLength.Value.ToString(CultureInfo.InvariantCulture); } else { str = null; } this.WriteElementString(xmlWriter3, str12, str); if (value) { this.WriteElementString(xmlWriter, str6, blobProps.ContentType); this.WriteElementString(xmlWriter, str7, blobProps.ContentEncoding); this.WriteElementString(xmlWriter, str8, blobProps.ContentLanguage); if (lboc.IsIncludingCrc64InResponse) { this.WriteElementString(xmlWriter, "Content-CRC64", blobProps.ContentCrc64); } if (lboc.IsUsingPropertiesElement) { this.WriteElementString(xmlWriter, str10, blobProps.ContentMD5); } if (lboc.IsIncludingCacheControlInResponse) { this.WriteElementString(xmlWriter, str9, blobProps.CacheControl); } if (lboc.IsIncludingContentDispositionInResponse) { this.WriteElementString(xmlWriter, "Content-Disposition", blobProps.ContentDisposition); } } if (lboc.IsIncludingBlobTypeInResponse) { if (blobProps.SequenceNumber.HasValue) { long num = blobProps.SequenceNumber.Value; this.WriteElementString(xmlWriter, "x-ms-blob-sequence-number", num.ToString()); } this.WriteElementString(xmlWriter, "BlobType", blobProps.BlobType); } if (lboc.IsIncludingLeaseStatusInResponse && blobProps.Snapshot == DateTime.MaxValue) { this.WriteElementString(xmlWriter, "LeaseStatus", blobProps.LeaseStatus); if (lboc.IsIncludingLeaseStateAndDurationInResponse) { if (!string.IsNullOrEmpty(blobProps.LeaseState)) { this.WriteElementString(xmlWriter, "LeaseState", blobProps.LeaseState); } if (!string.IsNullOrEmpty(blobProps.LeaseDuration)) { this.WriteElementString(xmlWriter, "LeaseDuration", blobProps.LeaseDuration); } } } if (lboc.IsIncludingCopyPropertiesInResponse) { if (!string.IsNullOrEmpty(blobProps.CopyId)) { this.WriteElementString(xmlWriter, "CopyId", blobProps.CopyId); } if (!string.IsNullOrEmpty(blobProps.CopySource)) { this.WriteElementString(xmlWriter, "CopySource", (this.obfuscateSourceUri ? HttpUtilities.ObfuscateSourceUri(blobProps.CopySource) : blobProps.CopySource)); } if (!string.IsNullOrEmpty(blobProps.CopyStatus)) { this.WriteElementString(xmlWriter, "CopyStatus", blobProps.CopyStatus); } if (!string.IsNullOrEmpty(blobProps.CopyStatusDescription)) { this.WriteElementString(xmlWriter, "CopyStatusDescription", blobProps.CopyStatusDescription); } if (!string.IsNullOrEmpty(blobProps.CopyProgress)) { this.WriteElementString(xmlWriter, "CopyProgress", blobProps.CopyProgress); } if (blobProps.CopyCompletionTime.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && !blobProps.CopyStatus.Equals("pending", StringComparison.OrdinalIgnoreCase)) { DateTime?copyCompletionTime = blobProps.CopyCompletionTime; this.WriteElementString(xmlWriter, "CopyCompletionTime", HttpUtilities.ConvertDateTimeToHttpString(copyCompletionTime.Value)); } } if (lboc.IsIncludingIncrementalCopy && blobProps.IsIncrementalCopy) { this.WriteElementString(xmlWriter, "IncrementalCopy", "true"); if (blobProps.LastCopySnapshot.HasValue && !string.IsNullOrEmpty(blobProps.CopyStatus) && blobProps.CopyStatus.Equals("success", StringComparison.OrdinalIgnoreCase)) { if (blobProps.LastCopySnapshot.Value <= DateTimeConstants.MinimumIncrementalCopySnapshotTime) { AlertsManager.AlertOrLogException("LastCopySnapshot set to Minimum value, while a valid timestamp was expected.", null, null); } DateTime?lastCopySnapshot = blobProps.LastCopySnapshot; this.WriteElementString(xmlWriter, "CopyDestinationSnapshot", HttpUtilities.ConvertSnapshotDateTimeToHttpString(lastCopySnapshot.Value)); } } if (lboc.IsIncludingEncryption) { this.WriteElementString(xmlWriter, "ServerEncrypted", (!blobProps.IsBlobEncrypted.HasValue || !blobProps.IsBlobEncrypted.Value ? "false" : "true")); } if (lboc.IsUsingPropertiesElement) { xmlWriter.WriteEndElement(); } if (value && lboc.IsFetchingMetadata) { MetadataEncoding.WriteMetadataToXml(xmlWriter, blobProps.Metadata, true, lboc.RequestVersion); } } xmlWriter.WriteEndElement(); }
protected override void EncodeEntry(Uri requestUrl, ListContainersOperationContext loc, IListContainersResultContainerProperties collProps, XmlWriter xmlWriter) { string httpString; string eTag; xmlWriter.WriteStartElement(this.XmlContainerElementName); xmlWriter.WriteElementString("Name", collProps.ContainerName); if (loc.IsIncludingUrlInResponse) { string str = string.Concat(HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path)), "/", collProps.ContainerName); xmlWriter.WriteElementString("Url", str); } if (loc.IsUsingPropertiesElement) { xmlWriter.WriteStartElement("Properties"); } string str1 = (loc.IsUsingPropertiesElement ? "Last-Modified" : "LastModified"); XmlWriter xmlWriter1 = xmlWriter; string str2 = str1; if (collProps.LastModifiedTime.HasValue) { httpString = HttpUtilities.ConvertDateTimeToHttpString(collProps.LastModifiedTime.Value); } else { httpString = null; } xmlWriter1.WriteElementString(str2, httpString); XmlWriter xmlWriter2 = xmlWriter; if (collProps.LastModifiedTime.HasValue) { DateTime?lastModifiedTime = collProps.LastModifiedTime; eTag = BasicHttpProcessor.GetETag(lastModifiedTime.Value, this.shouldEncloseEtagsInQuotes); } else { eTag = null; } xmlWriter2.WriteElementString("Etag", eTag); if (loc.IsIncludingLeaseStateAndDurationInResponse) { if (!string.IsNullOrEmpty(collProps.LeaseStatus)) { xmlWriter.WriteElementString("LeaseStatus", collProps.LeaseStatus); } if (!string.IsNullOrEmpty(collProps.LeaseState)) { xmlWriter.WriteElementString("LeaseState", collProps.LeaseState); } if (!string.IsNullOrEmpty(collProps.LeaseDuration)) { xmlWriter.WriteElementString("LeaseDuration", collProps.LeaseDuration); } } if (loc.IsIncludingShareQuotaInResponse) { long containerQuotaInGB = collProps.ContainerQuotaInGB; xmlWriter.WriteElementString("Quota", containerQuotaInGB.ToString(CultureInfo.InvariantCulture)); } if (loc.IsIncludingPublicAccessInResponse && !string.IsNullOrEmpty(collProps.PublicAccessLevel)) { if (Comparison.StringEqualsIgnoreCase(collProps.PublicAccessLevel, "container") || Comparison.StringEqualsIgnoreCase(collProps.PublicAccessLevel, bool.TrueString)) { xmlWriter.WriteElementString("PublicAccess", "container"); } else if (Comparison.StringEqualsIgnoreCase(collProps.PublicAccessLevel, "blob")) { xmlWriter.WriteElementString("PublicAccess", "blob"); } } if (loc.IsUsingPropertiesElement) { xmlWriter.WriteEndElement(); } if (loc.IsFetchingMetadata) { MetadataEncoding.WriteMetadataToXml(xmlWriter, collProps.Metadata, true, loc.RequestVersion); } xmlWriter.WriteEndElement(); }