public static IZaabyServer UseRepository(this IZaabyServer zaabyServer) { return(UseRepository(zaabyServer, type => type.GetInterfaces().Any(@interface => @interface.IsGenericType && @interface.GetGenericTypeDefinition() == typeof(IRepository <,>)))); }
public static IZaabyServer UseDDD(this IZaabyServer zaabyServer) { return(zaabyServer.UseApplicationService() .UseIntegrationEventHandler() .UseDomainService() .UseDomainEventHandler() .UseRepository()); }
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 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 UseEventBus(this IZaabyServer zaabyServer) { AllTypes = zaabyServer.AllTypes; var interfaceType = typeof(IIntegrationEventBus); var eventBusType = AllTypes.FirstOrDefault(type => interfaceType.IsAssignableFrom(type) && type.IsClass); if (eventBusType == null) { return(zaabyServer); } zaabyServer.AddSingleton(interfaceType, eventBusType); zaabyServer.RegisterServiceRunner(interfaceType, eventBusType); 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); }
public static IZaabyServer UseDomainEventHandler(this IZaabyServer zaabyServer) { var domainEventHandlerQuery = AllTypes.Where(type => type.IsClass); domainEventHandlerQuery = domainEventHandlerQuery.Where(type => type.BaseType != null && type.BaseType.IsGenericType && type.BaseType.GetGenericTypeDefinition() == typeof(DomainEventHandler <>)); var domainEventHandlers = domainEventHandlerQuery.ToList(); domainEventHandlers.ForEach(domainEventHandler => { zaabyServer.AddSingleton(domainEventHandler, domainEventHandler); zaabyServer.RegisterServiceRunner(domainEventHandler); }); 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 UseDomainEventHandler(this IZaabyServer zaabyServer) { return(UseDomainEventHandler(zaabyServer, type => type.IsClass && typeof(IDomainEventHandler).IsAssignableFrom(type))); }
public static IZaabyServer UseDomainService(this IZaabyServer zaabyServer) { return(UseDomainService(zaabyServer, type => type.IsClass && typeof(IDomainService).IsAssignableFrom(type))); }