public static void UseDistributedLock(this ITheSagaConfig config, SqlServerLockingOptions options) { if (string.IsNullOrEmpty(options?.ConnectionString)) { throw new Exception($"ConnectionString for TheSaga.Locking.DistributedLock cannot be empty"); } config.Services.AddSingleton <SqlServerLockingOptions>(ctx => options); config.Services.AddSingleton <ISagaLocking, SagaDistributedLocking>(); }
public SagaDistributedLocking(SqlServerLockingOptions lockingOptions) { this.lockingOptions = lockingOptions; this.locks = new Dictionary <Guid, IDisposable>(); }