FileShareService
using Relativity.Transfer.Dto;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Relativity.Transfer
{
internal class FileShareService : IFileShareService
{
private const string = "/Relativity.Rest/api/Relativity.StagingExplorer.Services.StagingManager.IStagingManagerModule/FileManagementService/";
private const string = "QueryAsync";
private const string = "QueryPropertiesAsync";
private const string = "GetItemAsync";
private const string = "GetItemsAsync";
private const string = "DeleteAsync";
private const string = "ItemExistsAsync";
private const string = "ItemsExistAsync";
private readonly IFileShareRestClient ;
private readonly int ;
private readonly bool ;
internal FileShareService(RelativityConnectionInfo connectionInfo, ClientConfiguration configuration, int fileShareId, ITransferLog log, bool throwExceptions = true)
{
if (connectionInfo == null)
throw new ArgumentNullException("connectionInfo");
if (log == null)
throw new ArgumentNullException("log");
if (fileShareId <= 0)
throw new ArgumentOutOfRangeException("fileShareId", fileShareId, "FileShare id should be greater than zero");
_fileShareRestClient = new FileShareRestClient(connectionInfo, configuration, log);
_fileShareId = fileShareId;
_throwExceptions = throwExceptions;
}
internal FileShareService(IFileShareRestClient restClient, int fileShareId, bool throwExceptions)
{
if (restClient == null)
throw new ArgumentNullException("restClient");
if (fileShareId <= 0)
throw new ArgumentOutOfRangeException("fileShareId", fileShareId, "FileShare id should be greater than zero");
_fileShareRestClient = restClient;
_fileShareId = fileShareId;
_throwExceptions = throwExceptions;
}
[AsyncStateMachine(typeof(<ItemExistsAsync>d__13))]
public Task<bool> (string path, CancellationToken token)
{
<ItemExistsAsync>d__13 stateMachine = default(<ItemExistsAsync>d__13);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
stateMachine.<>4__this = this;
stateMachine.path = path;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<ItemsExistAsync>d__14))]
public Task<bool> (IEnumerable<string> paths, CancellationToken token)
{
<ItemsExistAsync>d__14 stateMachine = default(<ItemsExistAsync>d__14);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
stateMachine.<>4__this = this;
stateMachine.paths = paths;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<DirectoryEmptyAsync>d__15))]
public Task<bool> (string path, CancellationToken token)
{
<DirectoryEmptyAsync>d__15 stateMachine = default(<DirectoryEmptyAsync>d__15);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
stateMachine.<>4__this = this;
stateMachine.path = path;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<GetFileShareItemAsync>d__16))]
public Task<FileShareItem> (string path, CancellationToken token)
{
<GetFileShareItemAsync>d__16 stateMachine = default(<GetFileShareItemAsync>d__16);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<FileShareItem>.Create();
stateMachine.<>4__this = this;
stateMachine.path = path;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<GetFileShareItemsAsync>d__17))]
public Task<IEnumerable<FileShareItem>> (IEnumerable<string> directories, IEnumerable<string> files, CancellationToken token)
{
<GetFileShareItemsAsync>d__17 stateMachine = default(<GetFileShareItemsAsync>d__17);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<IEnumerable<FileShareItem>>.Create();
stateMachine.<>4__this = this;
stateMachine.directories = directories;
stateMachine.files = files;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<BrowseDirectoryAsync>d__18))]
public Task<BrowseDirectoryResponseDto> (string path, int page, int pageSize, int enumerateMax, CancellationToken token)
{
<BrowseDirectoryAsync>d__18 stateMachine = default(<BrowseDirectoryAsync>d__18);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<BrowseDirectoryResponseDto>.Create();
stateMachine.<>4__this = this;
stateMachine.path = path;
stateMachine.page = page;
stateMachine.pageSize = pageSize;
stateMachine.enumerateMax = enumerateMax;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<GetItemAttributesAsync>d__19))]
public Task<QueryPropertiesResponseDto> (string path, CancellationToken token)
{
<GetItemAttributesAsync>d__19 stateMachine = default(<GetItemAttributesAsync>d__19);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<QueryPropertiesResponseDto>.Create();
stateMachine.<>4__this = this;
stateMachine.path = path;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<DeleteDirectoriesAsync>d__20))]
public Task (IEnumerable<string> paths, CancellationToken token)
{
<DeleteDirectoriesAsync>d__20 stateMachine = default(<DeleteDirectoriesAsync>d__20);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.paths = paths;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<DeleteFilesAsync>d__21))]
public Task (IEnumerable<string> paths, CancellationToken token)
{
<DeleteFilesAsync>d__21 stateMachine = default(<DeleteFilesAsync>d__21);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.paths = paths;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<DeleteAsync>d__22))]
private Task (IEnumerable<string> paths, bool isFile, CancellationToken token)
{
<DeleteAsync>d__22 stateMachine = default(<DeleteAsync>d__22);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.paths = paths;
stateMachine.isFile = isFile;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<SendFileShareMessage>d__23<, >))]
internal Task<TResponse> < , >(TRequest request, string command, CancellationToken token) where : FileShareResponseBaseDto, new
{
<SendFileShareMessage>d__23<TResponse, TRequest> stateMachine = default(<SendFileShareMessage>d__23<TResponse, TRequest>);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<TResponse>.Create();
stateMachine.<>4__this = this;
stateMachine.request = request;
stateMachine.command = command;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
internal bool (FileShareOperationErrorCode responseError)
{
return responseError == FileShareOperationErrorCode.Unknown;
}
internal static string (string path)
{
return path.Replace('/', '\\');
}
internal string (string path)
{
if (path.Length <= 1 || !path.EndsWith("\\"))
return path;
return path.Remove(path.Length - 1);
}
}
}