KeplerServiceBase
using Relativity.Services.ServiceProxy;
using Relativity.Transfer.Resources;
using System;
namespace Relativity.Transfer.Kepler
{
internal abstract class KeplerServiceBase
{
private const string _REST_API_PATH = "/relativity.rest/api/";
private readonly object lock = new object();
private ServiceFactory serviceFactory;
public RelativityConnectionInfo ConnectionInfo { get; }
public int MaxRetryAttempts { get; set; }
protected ITransferLog Log { get; }
protected KeplerServiceBase(RelativityConnectionInfo connectionInfo, ClientConfiguration configuration, ITransferLog log)
{
if (configuration == null)
throw new ArgumentNullException("configuration");
if (configuration.UseLegacyWebApi)
throw new ArgumentException(CoreStrings.InvalidCommunicationModeExceptionMessage, "UseLegacyWebApi");
if (log == null)
throw new ArgumentNullException("log");
Log = log;
if (connectionInfo == null)
throw new ArgumentNullException("connectionInfo");
ConnectionInfo = connectionInfo;
MaxRetryAttempts = configuration.MaxHttpRetryAttempts;
}
protected T CreateProxy<T>() where T : IDisposable
{
if (serviceFactory == null) {
lock (lock) {
if (serviceFactory == null) {
Credentials val = ConnectionInfo.Credential.CreateRelativityCredentials();
ServiceFactorySettings val2 = new ServiceFactorySettings(new Uri(ConnectionInfo.Host, "/relativity.rest/api/"), val);
serviceFactory = new ServiceFactory(val2);
}
}
}
return serviceFactory.CreateProxy<T>();
}
}
}