예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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>();
     }
 }
예제 #5
0
 public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options)
 {
     container.RegisterConditional(typeof(IRequestValidator <>), typeof(FluentRequestValidator <>), c => !c.Handled);
 }
예제 #6
0
        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>();
        }