本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
}
示例7: GetRelativeHttpPath
internal static string GetRelativeHttpPath(Uri path)
{
path.ArgumentNotNull("path");
return path.UserInfo + "/" + string.Join(string.Empty, path.Segments).TrimStart('/');
}
示例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);
}
示例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");
}
}
示例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);
}
}
}
}
}
示例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;
}
示例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;
}
示例13: GetComponentSettings
public async Task<IHttpResponseMessageAbstraction> GetComponentSettings(Uri componentUri)
{
componentUri.ArgumentNotNull("componentUri");
return await this.MakeAsyncGetRequest(componentUri);
}
示例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;
}
示例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;
}