Exemple #1
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);
        }
Exemple #2
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 #3
0
        public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options)
        {
            bool IfNotHandled(ConditionalContext c) => !c.Handled;

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

            container.Register(typeof(CreateRequestHandler <,>), assemblies);
            container.Register(typeof(CreateRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(CreateRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(CreateRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(CreateAllRequestHandler <,>), assemblies);
            container.Register(typeof(CreateAllRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(CreateAllRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(CreateAllRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(GetRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(GetRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(GetAllRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(GetAllRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(PagedGetAllRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(PagedGetAllRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(UpdateRequestHandler <,>), assemblies);
            container.Register(typeof(UpdateRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(UpdateRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(UpdateRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(UpdateAllRequestHandler <,>), assemblies);
            container.Register(typeof(UpdateAllRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(UpdateAllRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(UpdateAllRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(DeleteRequestHandler <,>), assemblies);
            container.Register(typeof(DeleteRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(DeleteRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(DeleteRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(DeleteAllRequestHandler <,>), assemblies);
            container.Register(typeof(DeleteAllRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(DeleteAllRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(DeleteAllRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(SaveRequestHandler <,>), assemblies);
            container.Register(typeof(SaveRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(SaveRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(SaveRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(MergeRequestHandler <,>), assemblies);
            container.Register(typeof(MergeRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(MergeRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(MergeRequestHandler <, ,>), IfNotHandled);

            container.Register(typeof(SynchronizeRequestHandler <,>), assemblies);
            container.Register(typeof(SynchronizeRequestHandler <, ,>), assemblies);
            container.RegisterConditional(typeof(IRequestHandler <>), typeof(SynchronizeRequestHandler <,>), IfNotHandled);
            container.RegisterConditional(typeof(IRequestHandler <,>), typeof(SynchronizeRequestHandler <, ,>), IfNotHandled);
        }
Exemple #4
0
 public override void Run(ServiceProviderContainer container, Assembly[] assemblies, CrudlessOptions options)
 {
     container.Register <IMediator>(() => new DynamicDispatchMediator(container, ScopeRequests));
 }