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); }
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); }
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); }
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); }
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); }
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); }
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); }