InstanceSettingService
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
namespace Relativity.Transfer
{
public class InstanceSettingService : IInstanceSettingService
{
public const string CloudInstanceSectionName = "Relativity.Core";
public const string CloudInstanceName = "CloudInstance";
private readonly RelativityConnectionInfo connectionInfo;
private readonly IInstanceSettingRetriever instanceSettingRetriever;
public RelativityConnectionInfo ConnectionInfo => connectionInfo;
public int MaxRetryAttempts { get; set; }
public double TimeoutSeconds { get; set; }
public InstanceSettingService(RelativityConnectionInfo connectionInfo, ITransferLog transferLog)
: this(connectionInfo, transferLog, 5, 300)
{
}
public InstanceSettingService(RelativityConnectionInfo connectionInfo, ITransferLog transferLog, int maxRetryAttempts, double timeoutSeconds)
{
if (connectionInfo == null)
throw new ArgumentNullException("connectionInfo");
if (transferLog == null)
throw new ArgumentNullException("transferLog");
this.connectionInfo = connectionInfo;
MaxRetryAttempts = maxRetryAttempts;
TimeoutSeconds = timeoutSeconds;
instanceSettingRetriever = new InstanceSettingsLegacyKeplerRetriever(connectionInfo, transferLog, maxRetryAttempts, timeoutSeconds);
}
internal InstanceSettingService(IInstanceSettingRetriever instanceSettingRetriever, RelativityConnectionInfo connectionInfo, ITransferLog transferLog)
: this(connectionInfo, transferLog)
{
this.instanceSettingRetriever = instanceSettingRetriever;
}
[AsyncStateMachine(typeof(<GetAllAsync>d__17))]
public Task<IEnumerable<InstanceSetting>> GetAllAsync(CancellationToken token)
{
<GetAllAsync>d__17 stateMachine = default(<GetAllAsync>d__17);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<IEnumerable<InstanceSetting>>.Create();
stateMachine.<>4__this = this;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<GetCloudInstanceAsync>d__18))]
public Task<bool> GetCloudInstanceAsync(CancellationToken token)
{
<GetCloudInstanceAsync>d__18 stateMachine = default(<GetCloudInstanceAsync>d__18);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
stateMachine.<>4__this = this;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<GetInstanceIdAsync>d__19))]
public Task<Guid?> GetInstanceIdAsync(CancellationToken token)
{
<GetInstanceIdAsync>d__19 stateMachine = default(<GetInstanceIdAsync>d__19);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<Guid?>.Create();
stateMachine.<>4__this = this;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
[AsyncStateMachine(typeof(<GetSingleAsync>d__20))]
public Task<InstanceSetting> GetSingleAsync(string section, string name, CancellationToken token)
{
<GetSingleAsync>d__20 stateMachine = default(<GetSingleAsync>d__20);
stateMachine.<>t__builder = AsyncTaskMethodBuilder<InstanceSetting>.Create();
stateMachine.<>4__this = this;
stateMachine.section = section;
stateMachine.name = name;
stateMachine.token = token;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
}
}