AsperaAutoConfigService
class AsperaAutoConfigService
using Relativity.Transfer.Aspera.Resources;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Relativity.Transfer.Aspera
{
internal class AsperaAutoConfigService
{
private readonly IWorkspaceService workspaceService;
private readonly ITransferLog logger;
public AsperaAutoConfigService(IWorkspaceService service, ITransferLog logger)
{
if (service == null)
throw new ArgumentNullException("service");
if (logger == null)
throw new ArgumentNullException("logger");
workspaceService = service;
this.logger = logger;
}
[AsyncStateMachine(typeof(<ApplyAsync>d__3))]
public Task ApplyAsync(ClientConfiguration configuration, CancellationToken token)
{
<ApplyAsync>d__3 stateMachine = default(<ApplyAsync>d__3);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.configuration = configuration;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
private static void ValidateCredential(Credential credential)
{
try {
AsperaCredential.Validate(credential);
} catch (ArgumentException innerException) {
throw new TransferException(AsperaStrings.AsperaSpecifiedCredentialFieldsExceptionMessage, innerException);
}
}
private static Credential GetSerializedCredential(ClientConfiguration configuration)
{
Uri result = null;
if (configuration.ContainsKey("aspera-host"))
Uri.TryCreate(configuration["aspera-host"] as string, UriKind.RelativeOrAbsolute, out result);
string value = null;
if (configuration.ContainsKey("aspera-account-username"))
value = (configuration["aspera-account-username"] as string);
string value2 = null;
if (configuration.ContainsKey("aspera-account-password"))
value2 = (configuration["aspera-account-password"] as string);
if (!(result == (Uri)null) && !string.IsNullOrEmpty(value) && !string.IsNullOrEmpty(value2))
try {
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary.Add("url", result.ToString());
dictionary.Add("accountName", value);
dictionary.Add("accountPassword", value2);
Credential credential = new Credential(1, "Serialized", "Aspera", dictionary);
AsperaCredential.Validate(credential);
return credential;
} catch (ArgumentException innerException) {
throw new TransferException(AsperaStrings.AsperaSpecifiedCredentialFieldsExceptionMessage, innerException);
}
return null;
}
[AsyncStateMachine(typeof(<GetWorkspaceCredentialAsync>d__6))]
private Task<Credential> GetWorkspaceCredentialAsync(ClientConfiguration configuration, CancellationToken token)
{
<GetWorkspaceCredentialAsync>d__6 stateMachine = default(<GetWorkspaceCredentialAsync>d__6);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Credential>.Create();
stateMachine.<>4__this = this;
stateMachine.configuration = configuration;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
}
}