public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options) { switch (_transactionType) { default: case TransactionType.TransactionScope: container.RegisterDecorator(typeof(IRequestHandler <>), typeof(TransactionScopeTransactionDecorator <>), ShouldDecorate()); container.RegisterDecorator(typeof(IRequestHandler <,>), typeof(TransactionScopeTransactionDecorator <,>), ShouldDecorate()); break; case TransactionType.EntityFramework: container.RegisterDecorator(typeof(IRequestHandler <>), typeof(EntityFrameworkTransactionDecorator <>), ShouldDecorate()); container.RegisterDecorator(typeof(IRequestHandler <,>), typeof(EntityFrameworkTransactionDecorator <,>), ShouldDecorate()); break; } }
public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options) { container.RegisterScoped(typeof(DbContextFactory), DbContextFactoryType); container.RegisterScoped <IEntityContext, EntityFrameworkContext>(); var dataAgent = new EntityFrameworkDataAgent(); container.RegisterInstance <ICreateDataAgent>(dataAgent); container.RegisterInstance <IUpdateDataAgent>(dataAgent); container.RegisterInstance <IDeleteDataAgent>(dataAgent); container.RegisterInstance <IBulkCreateDataAgent>(dataAgent); container.RegisterInstance <IBulkUpdateDataAgent>(dataAgent); container.RegisterInstance <IBulkDeleteDataAgent>(dataAgent); }
public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options) { var requestAssemblies = new[] { typeof(CrudlessRequest <>).Assembly }; container.Register(typeof(CrudlessRequest <>), requestAssemblies); container.Register(typeof(CrudlessRequest <,>), requestAssemblies); container.RegisterConditional(typeof(Turner.Infrastructure.Mediator.IRequestHandler <>), typeof(CrudlessRequestHandler <>), IfNotHandled); container.RegisterConditional(typeof(Turner.Infrastructure.Mediator.IRequestHandler <,>), typeof(CrudlessRequestHandler <,>), IfNotHandled); }
public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options) { using (var scope = container.AllowOverrides()) { container.RegisterSingleton <IDeleteDataAgent, SoftDeleteDataAgent>(); container.RegisterSingleton <IBulkDeleteDataAgent, SoftDeleteDataAgent>(); } }
public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options) { container.RegisterConditional(typeof(IRequestValidator <>), typeof(FluentRequestValidator <>), c => !c.Handled); }
public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options) { BulkConfigurationManager.Clear(); using (container.AllowOverrides()) { var bulkAgent = new BulkDataAgent(); if ((_extensions & BulkExtensions.Create) == BulkExtensions.Create) { container.RegisterInstance <IBulkCreateDataAgent>(bulkAgent); } if ((_extensions & BulkExtensions.Update) == BulkExtensions.Update) { container.RegisterInstance <IBulkUpdateDataAgent>(bulkAgent); } if ((_extensions & BulkExtensions.Delete) == BulkExtensions.Delete) { container.RegisterInstance <IBulkDeleteDataAgent>(bulkAgent); } } EntityFrameworkManager.ContextFactory = context => container.ProvideInstance <DbContext>(); }