Exemple #1
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>();
        }
Exemple #2
0
        public void Initialize()
        {
            var assemblies    = _assemblies.Distinct().ToArray();
            var configManager = new CrudlessConfigManager(_container, assemblies);

            using (var scope = _container.AllowOverrides())
            {
                _container.RegisterInstance(configManager);
                _container.RegisterInstance(_container);
            }

            _tasks.ForEach(t => t.Run(_container, assemblies, _options));
        }
Exemple #3
0
 public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options)
 {
     if (_mapper != null)
     {
         using (var scope = container.AllowOverrides())
             container.RegisterInstance(_mapper);
     }
 }
Exemple #4
0
        public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options)
        {
            var shouldValidate      = ShouldValidate(options.ValidateAllRequests);
            var shouldMaybeValidate = ShouldMaybeValidate(options.ValidateAllRequests);

            container.Register(typeof(IRequestValidator <>), assemblies);

            container.RegisterInstance(new ValidatorFactory(container));

            container.RegisterDecorator(typeof(IRequestHandler <>), ValidatorFactory, shouldValidate);
            container.RegisterDecorator(typeof(IRequestHandler <,>), ValidatorFactory, shouldValidate);

            container.RegisterDecorator(typeof(IRequestHandler <>), typeof(MaybeValidateDecorator <>), shouldMaybeValidate);
            container.RegisterDecorator(typeof(IRequestHandler <,>), typeof(MaybeValidateDecorator <,>), shouldMaybeValidate);
        }
Exemple #5
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);
        }