当前位置: 首页>>代码示例>>C#>>正文


C# UriBuilder.AddPathSegment方法代码示例

本文整理汇总了C#中System.UriBuilder.AddPathSegment方法的典型用法代码示例。如果您正苦于以下问题:C# UriBuilder.AddPathSegment方法的具体用法?C# UriBuilder.AddPathSegment怎么用?C# UriBuilder.AddPathSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.UriBuilder的用法示例。


在下文中一共展示了UriBuilder.AddPathSegment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializeBlobListing

 static void SerializeBlobListing(XmlWriter writer, BlobListHandler.BlobListResults results)
 {
     var uri = new UriBuilder(results.ServiceEndpoint);
     writer.WriteStartElement("EnumerationResults");
     if (results.RequestVersion >= StorageServiceVersions.Version_2013_08_15)
     {
         writer.WriteAttributeString("ServiceEndpoint", results.ServiceEndpoint);
         writer.WriteAttributeString("ContainerName", results.ContainerName);
     }
     else
     {
         uri = uri.AddPathSegment(results.ContainerName);
         writer.WriteAttributeString("ContainerName", uri.Uri.ToString());
     }
     writer.WriteElementStringIfNotNull("Prefix", results.Prefix);
     writer.WriteElementStringIfNotNull("Marker", results.Marker);
     writer.WriteElementStringIfNotNull("MaxResults", results.IndicatedMaxResults);
     writer.WriteElementStringIfNotNull("Delimiter", results.Delimiter);
     writer.WriteStartElement("Blobs");
     IListBlobItem nextBlob = null;
     int blobCount = 0;
     foreach (var blob in results.Blobs)
     {
         if (++blobCount > results.MaxResults)
         {
             nextBlob = blob;
             break;
         }
         else if (blob is ICloudBlob)
         {
             var realBlob = (ICloudBlob)blob;
             writer.WriteStartElement("Blob");
             writer.WriteElementString("Name", realBlob.Name);
             if (results.RequestVersion < StorageServiceVersions.Version_2013_08_15)
             {
                 writer.WriteElementString("Url", uri.AddPathSegment(realBlob.Name).Uri.ToString());
             }
             if (realBlob.IsSnapshot && results.IncludeDetails.IsFlagSet(BlobListingDetails.Snapshots))
             {
                 writer.WriteElementString("Snapshot", realBlob.SnapshotTime, true);
             }
             writer.WriteStartElement("Properties");
             writer.WriteElementString("Last-Modified", realBlob.Properties.LastModified);
             writer.WriteElementString("Etag", realBlob.Properties.ETag);
             writer.WriteElementString("Content-Length", realBlob.Properties.Length.ToString());
             writer.WriteElementString("Content-Type", realBlob.Properties.ContentType);
             writer.WriteElementString("Content-Encoding", realBlob.Properties.ContentEncoding);
             writer.WriteElementString("Content-Language", realBlob.Properties.ContentLanguage);
             writer.WriteElementString("Content-MD5", realBlob.Properties.ContentMD5);
             writer.WriteElementString("Cache-Control", realBlob.Properties.CacheControl);
             writer.WriteElementString("Content-Disposition", realBlob.Properties.ContentDisposition);
             writer.WriteElementStringIfNotNull("x-ms-blob-sequence-number", realBlob.Properties.PageBlobSequenceNumber);
             writer.WriteElementStringIfNotEnumValue("BlobType", realBlob.Properties.BlobType, BlobType.Unspecified, false);
             if (results.RequestVersion >= StorageServiceVersions.Version_2012_02_12)
             {
                 writer.WriteElementStringIfNotEnumValue("LeaseStatus", realBlob.Properties.LeaseStatus, LeaseStatus.Unspecified);
                 writer.WriteElementStringIfNotEnumValue("LeaseState", realBlob.Properties.LeaseState, LeaseState.Unspecified);
                 writer.WriteElementStringIfNotEnumValue("LeaseDuration", realBlob.Properties.LeaseDuration, LeaseDuration.Unspecified);
             }
             if (results.IncludeDetails.IsFlagSet(BlobListingDetails.Copy) && realBlob.CopyState != null)
             {
                 writer.WriteElementStringIfNotNull("CopyId", realBlob.CopyState.CopyId);
                 writer.WriteElementStringIfNotEnumValue("CopyStatus", realBlob.CopyState.Status, CopyStatus.Invalid);
                 writer.WriteElementStringIfNotNull("CopySource", realBlob.CopyState.Source.ToString());
                 writer.WriteElementString("CopyProgress", String.Format("{0}/{1}", realBlob.CopyState.BytesCopied, realBlob.CopyState.TotalBytes));
                 writer.WriteElementStringIfNotNull("CopyCompletionTime", realBlob.CopyState.CompletionTime);
                 writer.WriteElementStringIfNotNull("CopyStatusDescription", realBlob.CopyState.StatusDescription);
             }
             writer.WriteEndElement();       // Properties
             if (results.IncludeDetails.IsFlagSet(BlobListingDetails.Metadata))
             {
                 writer.WriteStartElement("Metadata");
                 foreach (var metadataItem in realBlob.Metadata)
                 {
                     writer.WriteElementString(metadataItem.Key, metadataItem.Value);
                 }
                 writer.WriteEndElement();   // Metadata
             }
             writer.WriteEndElement();       // Blob
         }
         else if (blob is CloudBlobDirectory)
         {
             writer.WriteStartElement("BlobPrefix");
             writer.WriteElementString("Name", ((CloudBlobDirectory)blob).Prefix);
             writer.WriteEndElement();
         }
         else
         {
             System.Diagnostics.Debug.Assert(false, "Unexpected blob listing item");
         }
     }
     writer.WriteEndElement();           // Blobs
     if (nextBlob != null)
     {
         writer.WriteElementString("NextMarker", BlobListHandler.GetMarkerForBlob(nextBlob));
     }
     writer.WriteEndElement();           // EnumerationResults
 }
开发者ID:farukc,项目名称:Dash,代码行数:98,代码来源:ContainerController.cs

示例2: SerializeContainerListing

 static void SerializeContainerListing(XmlWriter writer, ContainerListResults results)
 {
     writer.WriteStartElement("EnumerationResults");
     var uri = new UriBuilder(results.ServiceEndpoint);
     if (results.RequestVersion >= StorageServiceVersions.Version_2013_08_15)
     {
         writer.WriteAttributeString("ServiceEndpoint", results.ServiceEndpoint);
     }
     else
     {
         writer.WriteAttributeString("AccountName", results.ServiceEndpoint);
     }
     writer.WriteElementStringIfNotNull("Prefix", results.Prefix);
     writer.WriteElementStringIfNotNull("Marker", results.Marker);
     writer.WriteElementStringIfNotNull("MaxResults", results.MaxResults);
     writer.WriteStartElement("Containers");
     foreach (var container in results.Containers.Results)
     {
         writer.WriteStartElement("Container");
         writer.WriteElementString("Name", container.Name);
         if (results.RequestVersion < StorageServiceVersions.Version_2013_08_15)
         {
             writer.WriteElementString("Url", uri.AddPathSegment(container.Name).Uri.ToString());
         }
         writer.WriteStartElement("Properties");
         writer.WriteElementString("Last-Modified", container.Properties.LastModified);
         writer.WriteElementString("Etag", container.Properties.ETag);
         if (results.RequestVersion >= StorageServiceVersions.Version_2012_02_12)
         {
             writer.WriteElementStringIfNotEnumValue("LeaseStatus", container.Properties.LeaseStatus, LeaseStatus.Unspecified);
             writer.WriteElementStringIfNotEnumValue("LeaseState", container.Properties.LeaseState, LeaseState.Unspecified);
             writer.WriteElementStringIfNotEnumValue("LeaseDuration", container.Properties.LeaseDuration, LeaseDuration.Unspecified);
         }
         writer.WriteEndElement();       // Properties
         if (results.IncludeDetails.IsFlagSet(ContainerListingDetails.Metadata))
         {
             writer.WriteStartElement("Metadata");
             foreach (var metadataItem in container.Metadata)
             {
                 writer.WriteElementString(metadataItem.Key, metadataItem.Value);
             }
             writer.WriteEndElement();   // Metadata
         }
         writer.WriteEndElement();       // Container
     }
     writer.WriteEndElement();           // Containers
     if (results.Containers.ContinuationToken != null)
     {
         writer.WriteElementStringIfNotNull("NextMarker", results.Containers.ContinuationToken.NextMarker);
     }
     writer.WriteEndElement();           // EnumerationResults 
 }
开发者ID:farukc,项目名称:Dash,代码行数:52,代码来源:AccountController.cs


注:本文中的System.UriBuilder.AddPathSegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。