Ejemplo n.º 1
0
        public static IZaabyServer UseDomainEventHandler(this IZaabyServer zaabyServer)
        {
            var domainEventSubscriberTypes = AllTypes
                                             .Where(type => type.IsClass && typeof(IDomainEventHandler).IsAssignableFrom(type)).ToList();

            domainEventSubscriberTypes.ForEach(domainEventSubscriberType =>
                                               zaabyServer.AddScoped(domainEventSubscriberType));
            zaabyServer.AddScoped(typeof(IDomainEventPublisher), typeof(DomainEventPublisher));
            zaabyServer.AddSingleton <DomainEventHandlerProvider>();
            return(zaabyServer);
        }
Ejemplo n.º 2
0
        public static IZaabyServer UseDomainEventHandler(this IZaabyServer zaabyServer,
                                                         Func <Type, bool> domainEventHandlerDefinition)
        {
            var domainEventSubscriberTypes = AllTypes
                                             .Where(domainEventHandlerDefinition).ToList();

            domainEventSubscriberTypes.ForEach(domainEventSubscriberType =>
                                               zaabyServer.AddScoped(domainEventSubscriberType));
            zaabyServer.AddScoped(typeof(IDomainEventPublisher), typeof(DomainEventPublisher));
            zaabyServer.AddSingleton <DomainEventHandlerProvider>();
            return(zaabyServer);
        }
Ejemplo n.º 3
0
        public static IZaabyServer UseDomainService(this IZaabyServer zaabyServer)
        {
            var domainServiceTypes = AllTypes
                                     .Where(type => type.IsClass && typeof(IDomainService).IsAssignableFrom(type)).ToList();

            domainServiceTypes.ForEach(integrationEventSubscriberType =>
                                       zaabyServer.AddScoped(integrationEventSubscriberType));
            return(zaabyServer);
        }
Ejemplo n.º 4
0
        public static IZaabyServer UseIntegrationEventHandler(this IZaabyServer zaabyServer)
        {
            var integrationEventSubscriberTypes = AllTypes
                                                  .Where(type => type.IsClass && typeof(IIntegrationEventHandler).IsAssignableFrom(type)).ToList();

            integrationEventSubscriberTypes.ForEach(integrationEventSubscriberType =>
                                                    zaabyServer.AddScoped(integrationEventSubscriberType));
            return(zaabyServer);
        }
Ejemplo n.º 5
0
        public static IZaabyServer UseDomainService(this IZaabyServer zaabyServer,
                                                    Func <Type, bool> domainServiceTypeDefinition)
        {
            var domainServiceTypes = AllTypes
                                     .Where(domainServiceTypeDefinition).ToList();

            domainServiceTypes.ForEach(integrationEventSubscriberType =>
                                       zaabyServer.AddScoped(integrationEventSubscriberType));
            return(zaabyServer);
        }
Ejemplo n.º 6
0
        public static IZaabyServer UseIntegrationEventHandler(this IZaabyServer zaabyServer,
                                                              Func <Type, bool> integrationEventHandlerTypeDefinition)
        {
            var integrationEventSubscriberTypes = AllTypes
                                                  .Where(integrationEventHandlerTypeDefinition).ToList();

            integrationEventSubscriberTypes.ForEach(integrationEventSubscriberType =>
                                                    zaabyServer.AddScoped(integrationEventSubscriberType));
            return(zaabyServer);
        }
        public static IZaabyServer UseDomainService(this IZaabyServer zaabyServer)
        {
            var domainServiceQuery = AllTypes.Where(type => type.IsClass);

            domainServiceQuery = domainServiceQuery.Where(type => typeof(IDomainService).IsAssignableFrom(type));

            var domainServices = domainServiceQuery.ToList();

            domainServices.ForEach(domainService => zaabyServer.AddScoped(domainService, domainService));
            return(zaabyServer);
        }
Ejemplo n.º 8
0
        public static IZaabyServer UseRepository(this IZaabyServer zaabyServer,
                                                 Func <Type, bool> repositoryTypeDefinition)
        {
            var repositoryInterfaces =
                AllTypes.Where(type => type.IsInterface && repositoryTypeDefinition.Invoke(type));

            var implementRepositories = AllTypes
                                        .Where(type => type.IsClass && repositoryInterfaces.Any(i => i.IsAssignableFrom(type)))
                                        .ToList();

            implementRepositories.ForEach(repository =>
                                          zaabyServer.AddScoped(repository.GetInterfaces().First(i => repositoryInterfaces.Contains(i)),
                                                                repository));

            var repositories = AllTypes.Where(type => type.IsClass && repositoryTypeDefinition.Invoke(type)).ToList();

            repositories.ForEach(repository => zaabyServer.AddScoped(repository));

            return(zaabyServer);
        }
        public static IZaabyServer UseRepository(this IZaabyServer zaabyServer)
        {
            var allInterfaces = AllTypes.Where(type => type.IsInterface);

            var repositoryInterfaces = allInterfaces.Where(type => type.GetInterfaces().Any(@interface =>
                                                                                            @interface.IsGenericType && @interface.GetGenericTypeDefinition() == typeof(IRepository <,>)));

            var implementRepositories = AllTypes
                                        .Where(type => type.IsClass && repositoryInterfaces.Any(i => i.IsAssignableFrom(type)))
                                        .ToList();

            implementRepositories.ForEach(repository =>
                                          zaabyServer.AddScoped(repository.GetInterfaces().First(i => repositoryInterfaces.Contains(i)),
                                                                repository));
            return(zaabyServer);
        }