22using Microsoft . Extensions . DependencyInjection ;
33using Shuttle . Core . Contract ;
44
5- namespace Shuttle . Core . TransactionScope
5+ namespace Shuttle . Core . TransactionScope ;
6+
7+ public static class ServiceCollectionExtensions
68{
7- public static class ServiceCollectionExtensions
9+ public static IServiceCollection AddTransactionScope ( this IServiceCollection services , Action < TransactionScopeBuilder > ? builder = null )
810 {
9- public static IServiceCollection AddTransactionScope ( this IServiceCollection services , Action < TransactionScopeBuilder > builder = null )
10- {
11- Guard . AgainstNull ( services , nameof ( services ) ) ;
11+ Guard . AgainstNull ( services ) ;
1212
13- var transactionScopeBuilder = new TransactionScopeBuilder ( services ) ;
13+ var transactionScopeBuilder = new TransactionScopeBuilder ( services ) ;
1414
15- builder ? . Invoke ( transactionScopeBuilder ) ;
15+ builder ? . Invoke ( transactionScopeBuilder ) ;
1616
17- services . AddOptions < TransactionScopeOptions > ( ) . Configure ( options =>
18- {
19- options . IsolationLevel = transactionScopeBuilder . Options . IsolationLevel ;
20- options . Timeout = transactionScopeBuilder . Options . Timeout ;
21- options . Enabled = transactionScopeBuilder . Options . Enabled ;
22- } ) ;
17+ services . AddOptions < TransactionScopeOptions > ( ) . Configure ( options =>
18+ {
19+ options . IsolationLevel = transactionScopeBuilder . Options . IsolationLevel ;
20+ options . Timeout = transactionScopeBuilder . Options . Timeout ;
21+ options . Enabled = transactionScopeBuilder . Options . Enabled ;
22+ } ) ;
2323
24- if ( services . Contains ( ServiceDescriptor . Singleton < ITransactionScopeFactory , TransactionScopeFactory > ( ) ) )
25- {
26- throw new InvalidOperationException ( Resources . AddTransactionScopeFactoryException ) ;
27- }
24+ if ( services . Contains ( ServiceDescriptor . Singleton < ITransactionScopeFactory , TransactionScopeFactory > ( ) ) )
25+ {
26+ throw new InvalidOperationException ( Resources . AddTransactionScopeFactoryException ) ;
27+ }
2828
29- services . AddSingleton < ITransactionScopeFactory , TransactionScopeFactory > ( ) ;
29+ services . AddSingleton < ITransactionScopeFactory , TransactionScopeFactory > ( ) ;
3030
31- return services ;
32- }
31+ return services ;
3332 }
3433}
0 commit comments