本文整理汇总了C#中FileRequestOptions类的典型用法代码示例。如果您正苦于以下问题:C# FileRequestOptions类的具体用法?C# FileRequestOptions怎么用?C# FileRequestOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileRequestOptions类属于命名空间,在下文中一共展示了FileRequestOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginOpenRead
public virtual ICancellableAsyncResult BeginOpenRead(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
{
StorageAsyncResult<Stream> storageAsyncResult = new StorageAsyncResult<Stream>(callback, state);
operationContext = operationContext ?? new OperationContext();
ICancellableAsyncResult result = this.BeginFetchAttributes(
accessCondition,
options,
operationContext,
ar =>
{
try
{
this.EndFetchAttributes(ar);
storageAsyncResult.UpdateCompletedSynchronously(ar.CompletedSynchronously);
AccessCondition streamAccessCondition = AccessCondition.CloneConditionWithETag(accessCondition, this.Properties.ETag);
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false);
storageAsyncResult.Result = new FileReadStream(this, streamAccessCondition, modifiedOptions, operationContext);
storageAsyncResult.OnComplete();
}
catch (Exception e)
{
storageAsyncResult.OnComplete(e);
}
},
null /* state */);
storageAsyncResult.CancelDelegate = result.Cancel;
return storageAsyncResult;
}
示例2: FileOpen
/// <inheritdoc />
public override Stream FileOpen(Database db, FileAccess fileAccess, ref string errorMessage, FileMode fileMode = FileMode.Open, bool excusiveAccess = false, int waitOverride = -1, bool signalError = true)
{
if (waitOverride == -1)
waitOverride = WaitForLockMilliseconds;
if (db.FileStream != null && ((db.FileStream.CanRead == false && fileAccess == FileAccess.Read) ||
(db.FileStream.CanWrite == false && (excusiveAccess || fileAccess == FileAccess.ReadWrite))))
{
db.FileStream.Dispose();
db.FileStream = null;
}
if (db.FileStream == null)
if (excusiveAccess)
{
CloudFile cloudFile = m_databaseDir.GetFileReference(db.FileInfo.Name);
FileRequestOptions fileRequestOptions = new FileRequestOptions();
fileRequestOptions.ServerTimeout = TimeSpan.FromMilliseconds(waitOverride);
fileRequestOptions.ParallelOperationThreadCount = 1;
if (fileAccess == FileAccess.Read)
db.FileStream = cloudFile.OpenRead(null, fileRequestOptions);
else
db.FileStream = cloudFile.OpenWrite(s_initialFileSize, null, fileRequestOptions);
//db.FileInfo, fileAccess, ref errorMessage, FileShare.None, fileMode, waitOverride, UseExternalStorageApi, signalError);
}
else
{
CloudFile cloudFile = m_databaseDir.GetFileReference(db.FileInfo.Name);
FileRequestOptions fileRequestOptions = new FileRequestOptions();
fileRequestOptions.ServerTimeout = TimeSpan.FromMilliseconds(waitOverride);
if (fileAccess == FileAccess.Read)
db.FileStream = cloudFile.OpenRead(null, fileRequestOptions);
else
db.FileStream = cloudFile.OpenWrite(s_initialFileSize, null, fileRequestOptions);
}
return db.FileStream;
}
示例3: SerializableFileRequestOptions
/// <summary>
/// Initializes a new instance of the <see cref="SerializableFileRequestOptions"/> class.
/// </summary>
/// <param name="info">Serialization information.</param>
/// <param name="context">Streaming context.</param>
private SerializableFileRequestOptions(SerializationInfo info, StreamingContext context)
: base(info, context)
{
bool? disableContentMD5Validation = (bool?)info.GetValue(DisableContentMD5ValidationName, typeof(bool?));
TimeSpan? maximumExecutionTime = (TimeSpan?)info.GetValue(MaximumExecutionTimeName, typeof(TimeSpan?));
TimeSpan? serverTimeout = (TimeSpan?)info.GetValue(ServerTimeoutName, typeof(TimeSpan?));
bool? storeFileContentMD5 = (bool?)info.GetValue(StoreFileContentMD5Name, typeof(bool?));
bool? useTransactionalMD5 = (bool?)info.GetValue(UseTransactionalMD5Name, typeof(bool?));
if (null != disableContentMD5Validation
|| null != maximumExecutionTime
|| null != serverTimeout
|| null != storeFileContentMD5
|| null != useTransactionalMD5)
{
this.fileRequestOptions = Transfer_RequestOptions.DefaultFileRequestOptions;
this.fileRequestOptions.DisableContentMD5Validation = disableContentMD5Validation;
this.fileRequestOptions.MaximumExecutionTime = maximumExecutionTime;
this.fileRequestOptions.ServerTimeout = serverTimeout;
this.fileRequestOptions.StoreFileContentMD5 = storeFileContentMD5;
this.fileRequestOptions.UseTransactionalMD5 = useTransactionalMD5;
}
else
{
this.fileRequestOptions = null;
}
}
示例4: OpenRead
public virtual Stream OpenRead(AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
operationContext = operationContext ?? new OperationContext();
this.FetchAttributes(accessCondition, options, operationContext);
AccessCondition streamAccessCondition = AccessCondition.CloneConditionWithETag(accessCondition, this.Properties.ETag);
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false);
return new FileReadStream(this, streamAccessCondition, modifiedOptions, operationContext);
}
示例5: Create
public virtual void Create(FileRequestOptions requestOptions = null, OperationContext operationContext = null)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(requestOptions, this.ServiceClient);
Executor.ExecuteSync(
this.CreateDirectoryImpl(modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext);
}
示例6: DownloadTextAsync
public static async Task<string> DownloadTextAsync(CloudFile file, Encoding encoding, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
using (MemoryStream stream = new MemoryStream())
{
await file.DownloadToStreamAsync(stream, accessCondition, options, operationContext);
return encoding.GetString(stream.ToArray(), 0, (int)stream.Length);
}
}
示例7: CreateAsync
public IAsyncAction CreateAsync(FileRequestOptions options, OperationContext operationContext)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return AsyncInfo.Run(async (token) => await Executor.ExecuteAsyncNullReturn(
this.CreateDirectoryImpl(modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
token));
}
示例8: CreateAsync
public virtual Task CreateAsync(FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Task.Run(async() => await Executor.ExecuteAsyncNullReturn(
this.CreateDirectoryImpl(modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
cancellationToken), cancellationToken);
}
示例9: BeginCreate
public virtual ICancellableAsyncResult BeginCreate(FileRequestOptions options, OperationContext operationContext, AsyncCallback callback, object state)
{
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient);
return Executor.BeginExecuteAsync(
this.CreateDirectoryImpl(modifiedOptions),
modifiedOptions.RetryPolicy,
operationContext,
callback,
state);
}
示例10: UploadTextAsync
public static async Task UploadTextAsync(CloudFile file, string text, Encoding encoding, AccessCondition accessCondition = null, FileRequestOptions options = null, OperationContext operationContext = null)
{
byte[] textAsBytes = encoding.GetBytes(text);
using (MemoryStream stream = new MemoryStream())
{
stream.Write(textAsBytes, 0, textAsBytes.Length);
stream.Seek(0, SeekOrigin.Begin);
file.ServiceClient.DefaultRequestOptions.ParallelOperationThreadCount = 2;
await file.UploadFromStreamAsync(stream, accessCondition, options, operationContext);
}
}
示例11: FetchShareAttributesAsync
public Task FetchShareAttributesAsync(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken token)
{
if (this.availableShareNames.Contains(share.Name))
{
return TaskEx.FromResult(true);
}
else
{
throw new MockupException("ShareNotExist");
}
}
示例12: OpenReadAsync
public virtual Task<Stream> OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken)
{
operationContext = operationContext ?? new OperationContext();
return Task.Run<Stream>(async () =>
{
await this.FetchAttributesAsync(accessCondition, options, operationContext);
AccessCondition streamAccessCondition = AccessCondition.CloneConditionWithETag(accessCondition, this.Properties.ETag);
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false);
return new FileReadStream(this, streamAccessCondition, modifiedOptions, operationContext);
}, cancellationToken);
}
示例13: OpenReadAsync
public IAsyncOperation<IRandomAccessStreamWithContentType> OpenReadAsync(AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext)
{
operationContext = operationContext ?? new OperationContext();
return AsyncInfo.Run<IRandomAccessStreamWithContentType>(async (token) =>
{
await this.FetchAttributesAsync(accessCondition, options, operationContext);
AccessCondition streamAccessCondition = AccessCondition.CloneConditionWithETag(accessCondition, this.Properties.ETag);
FileRequestOptions modifiedOptions = FileRequestOptions.ApplyDefaults(options, this.ServiceClient, false);
return new FileReadStreamHelper(this, streamAccessCondition, modifiedOptions, operationContext);
});
}
示例14: ListFilesAndDirectoriesAsync
public static async Task<IEnumerable<IListFileItem>> ListFilesAndDirectoriesAsync(CloudFileDirectory directory, int? maxResults, FileRequestOptions options, OperationContext operationContext)
{
List<IListFileItem> results = new List<IListFileItem>();
FileContinuationToken token = null;
do
{
FileResultSegment resultSegment = await directory.ListFilesAndDirectoriesSegmentedAsync(maxResults, token, options, operationContext);
results.AddRange(resultSegment.Results);
token = resultSegment.ContinuationToken;
}
while (token != null);
return results;
}
示例15: WindowsPhoneDoesNotSupportMD5
public void WindowsPhoneDoesNotSupportMD5()
{
FileRequestOptions options = new FileRequestOptions();
Assert.ThrowsException<NotSupportedException>(
() => options.DisableContentMD5Validation = false,
"MD5 flags should not work on Windows Phone");
Assert.ThrowsException<NotSupportedException>(
() => options.UseTransactionalMD5 = true,
"MD5 flags should not work on Windows Phone");
Assert.ThrowsException<NotSupportedException>(
() => options.StoreFileContentMD5 = true,
"MD5 flags should not work on Windows Phone");
}