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


C# Uri.ArgumentNotNull方法代码示例

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


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

示例1: GetWasbStoragePath

        internal static Uri GetWasbStoragePath(Uri httpPath)
        {
            httpPath.ArgumentNotNull("httpPath");

            if (
                !(string.Equals(httpPath.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(httpPath.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)))
            {
                throw new ArgumentException("httpPath should have a uri scheme of http", "httpPath");
            }

            int segmentTakeCount = 1;
            string containerName = httpPath.Segments.First();
            if (containerName == "/" && httpPath.Segments.Length > segmentTakeCount)
            {
                containerName = httpPath.Segments.Skip(segmentTakeCount).FirstOrDefault();
                segmentTakeCount++;
            }

            string asvPath = string.Format(
                CultureInfo.InvariantCulture,
                "{0}://{1}@{2}/{3}",
                WabsProtocol,
                containerName.TrimEnd('/'),
                httpPath.Host,
                string.Join(string.Empty, httpPath.Segments.Skip(segmentTakeCount)));
            return new Uri(asvPath);
        }
开发者ID:takekazuomi,项目名称:azure-sdk-tools,代码行数:28,代码来源:AzureHDInsightStorageHandler.cs

示例2: ScannerInformation

        /// <summary>
        /// Initializes a new instance of the <see cref="ScannerInformation"/> class.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <param name="tableName">Name of the table.</param>
        public ScannerInformation(Uri location, string tableName)
        {
            location.ArgumentNotNull("location");
            tableName.ArgumentNotNullNorEmpty("tableName");

            Location = location;
            TableName = tableName;
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:13,代码来源:ScannerInformation.cs

示例3: Exists

 public async Task<bool> Exists(Uri path)
 {
     path.ArgumentNotNull("path");
     var httpPath = ConvertToHttpPath(path);
     this.AssertPathRootedToThisAccount(httpPath);
     var blobReference = await this.GetBlobReference(httpPath, false);
     return blobReference != null;
 }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:8,代码来源:WabStorageAbstraction.cs

示例4: ScannerInformation

        /// <summary>
        /// Initializes a new instance of the <see cref="ScannerInformation"/> class.
        /// </summary>
        /// <param name="location">The location.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="responseHeaderCollection">additional header information from the response</param>
        public ScannerInformation(Uri location, string tableName, WebHeaderCollection responseHeaderCollection)
        {
            location.ArgumentNotNull("location");
            tableName.ArgumentNotNullNorEmpty("tableName");
            responseHeaderCollection.ArgumentNotNull("responseHeaderCollection");

            Location = location;
            TableName = tableName;
            ResponseHeaderCollection = responseHeaderCollection;
        }
开发者ID:hdinsight,项目名称:hbase-sdk-for-net,代码行数:16,代码来源:ScannerInformation.cs

示例5: ClusterCredentials

        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterCredentials"/> class.
        /// </summary>
        /// <param name="clusterUri">The cluster URI.</param>
        /// <param name="userName">The username.</param>
        /// <param name="password">The password.</param>
        public ClusterCredentials(Uri clusterUri, string userName, SecureString password)
        {
            clusterUri.ArgumentNotNull("clusterUri");
            userName.ArgumentNotNullNorEmpty("username");
            password.ArgumentNotNull("securePassword");

            ClusterUri = clusterUri;
            UserName = userName;
            _clusterPassword = password.Copy();
            _clusterPassword.MakeReadOnly();
        }
开发者ID:gitter-badger,项目名称:hbase-sdk-for-net,代码行数:17,代码来源:ClusterCredentials.cs

示例6: Delete

 public void Delete(Uri path)
 {
     path.ArgumentNotNull("path");
     string localPath = path.LocalPath;
     var client = this.GetStorageClient();
     var container = client.GetContainerReference(this.credentials.ContainerName);
     localPath = localPath.TrimStart('/');
     foreach (CloudBlockBlob blob in container.ListBlobs(localPath, true, BlobListingDetails.None, null, null))
     {
         blob.Delete();
     }
 }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:12,代码来源:WabStorageAbstraction.cs

示例7: GetRelativeHttpPath

 internal static string GetRelativeHttpPath(Uri path)
 {
     path.ArgumentNotNull("path");
     return path.UserInfo + "/" + string.Join(string.Empty, path.Segments).TrimStart('/');
 }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:5,代码来源:WabStorageAbstraction.cs

示例8: ConvertToHttpPath

        internal static Uri ConvertToHttpPath(Uri asvPath)
        {
            asvPath.ArgumentNotNull("path");
            if (!string.Equals(asvPath.Scheme, Constants.WabsProtocol, StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("asvPath should have a uri scheme of asv", "asvPath");
            }

            string httpPath = string.Format(
                CultureInfo.InvariantCulture, "http://{0}/{1}{2}", asvPath.Host, asvPath.UserInfo, string.Join(string.Empty, asvPath.Segments));
            return new Uri(httpPath);
        }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:12,代码来源:WabStorageAbstraction.cs

示例9: AssertPathRootedToThisAccount

 private void AssertPathRootedToThisAccount(Uri path)
 {
     path.ArgumentNotNull("path");
     if (!string.Equals(this.StorageAccountUri.DnsSafeHost, path.DnsSafeHost, StringComparison.Ordinal))
     {
         throw new ArgumentException("Path is not rooted in the storage account.", "path");
     }
 }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:8,代码来源:WabStorageAbstraction.cs

示例10: DownloadToFile

        public async Task DownloadToFile(Uri path, string localFileName)
        {
            path.ArgumentNotNull("path");
            localFileName.ArgumentNotNullOrEmpty("localFileName");

            var httpPath = ConvertToHttpPath(path);
            this.AssertPathRootedToThisAccount(httpPath);

            var blobReference = await this.GetBlobReference(httpPath, true);

            // Read blob in chunks of up to 4MB
            long chunkSize = 4 * 1024 * 1024;

            if (blobReference.Properties.Length < chunkSize)
            {
                blobReference.DownloadToFile(localFileName, FileMode.OpenOrCreate);
            }
            else
            {
                byte[] buffer = new byte[chunkSize];
                using (var blobStream = blobReference.OpenRead())
                {
                    using (var fileStream = File.Create(localFileName))
                    {
                        int bytesRead;
                        while ((bytesRead = blobStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            fileStream.Write(buffer, 0, bytesRead);
                        }
                    }
                }
            }
        }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:33,代码来源:WabStorageAbstraction.cs

示例11: List

        public async Task<IEnumerable<Uri>> List(Uri path, bool recursive)
        {
            path.ArgumentNotNull("path");
            var httpPath = ConvertToHttpPath(path);
            this.AssertPathRootedToThisAccount(httpPath);
            var client = this.GetStorageClient();
            var directoryPath = GetRelativeHttpPath(path);
            var directoryContents = new List<Uri>();
            if (directoryPath == RootDirectoryPath)
            {
                var containers = client.ListContainers().ToList();
                directoryContents.AddRange(containers.Select(item => ConvertToAsvPath(item.Uri)));
            }
            else
            {
                var asyncResult = client.BeginListBlobsSegmented(directoryPath, null, null, null);
                var blobs = await Task.Factory.FromAsync(asyncResult, (result) => client.EndListBlobsSegmented(result));
                var blobDirectory = blobs.Results.FirstOrDefault(blob => blob is CloudBlobDirectory) as CloudBlobDirectory;
                if (blobDirectory != null)
                {
                    var blobItems = blobDirectory.ListBlobs(true).ToList();
                    directoryContents.AddRange(blobItems.Select(item => ConvertToAsvPath(item.Uri)));
                }
            }

            return directoryContents;
        }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:27,代码来源:WabStorageAbstraction.cs

示例12: Read

        public async Task<Stream> Read(Uri path)
        {
            path.ArgumentNotNull("path");
            var httpPath = ConvertToHttpPath(path);
            this.AssertPathRootedToThisAccount(httpPath);
            var blobReference = await this.GetBlobReference(httpPath, true);

            var blobStream = new MemoryStream();
            blobReference.DownloadToStream(blobStream);
            blobStream.Seek(0, SeekOrigin.Begin);

            return blobStream;
        }
开发者ID:sathishkkl,项目名称:hadoopsdk,代码行数:13,代码来源:WabStorageAbstraction.cs

示例13: GetComponentSettings

 public async Task<IHttpResponseMessageAbstraction> GetComponentSettings(Uri componentUri)
 {
     componentUri.ArgumentNotNull("componentUri");
     return await this.MakeAsyncGetRequest(componentUri);
 }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:5,代码来源:AzureHDInsightConfigurationRestClient.cs

示例14: ClusterCredentials

        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterCredentials"/> class.
        /// </summary>
        /// <param name="clusterUri">The cluster URI.</param>
        public ClusterCredentials(Uri clusterUri)
        {
            clusterUri.ArgumentNotNull("clusterUri");

            ClusterUri = clusterUri;
        }
开发者ID:pdlg-spotlight,项目名称:lambda-architecture,代码行数:10,代码来源:ClusterCredentials.cs

示例15: Read

        public async Task<Stream> Read(Uri path)
        {
            path.ArgumentNotNull("path");
            var httpPath = ConvertToHttpPath(path);
            this.AssertPathRootedToThisAccount(httpPath);
            var blobReference = await this.GetBlobReference(httpPath, true);

            var blobStream = await blobReference.OpenReadAsync();
            
            return blobStream;
        }
开发者ID:RossMerr,项目名称:azure-sdk-for-net,代码行数:11,代码来源:WabStorageAbstraction.cs


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