private static void TryAddCommandPipeline(IServiceCollection services, Type contract, ServiceLifetime lifetime) { var commandType = contract.GenericTypeArguments[0]; var pipelineType = PipelineTypes.Command.MakeGenericType(commandType); if (NeedCreatePipeline(services, pipelineType, lifetime)) { services.Add(new ServiceDescriptor( pipelineType, PipelineActivators.GetCommandPipelineActivator(commandType), lifetime)); } }
private static void TryAddQueryPipeline(IServiceCollection services, Type contract, ServiceLifetime lifetime) { var queryType = contract.GenericTypeArguments[0]; var resultType = contract.GenericTypeArguments[1]; var pipelineType = PipelineTypes.Query.MakeGenericType(queryType, resultType); if (NeedCreatePipeline(services, pipelineType, lifetime)) { services.Add(new ServiceDescriptor( pipelineType, PipelineActivators.GetQueryPipelineActivator(queryType, resultType), lifetime)); } }
public static IServiceCollection AddNotificationProcessor <TProcessor>(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Singleton) { var implementation = typeof(TProcessor); var processorInterfaces = PipelineTypes.NotificationProcessorTypes; var descriptor = BuildProcessorDescriptor(implementation, processorInterfaces, lifetime); services.Add(descriptor); var notificationType = descriptor.ServiceType.GenericTypeArguments[0]; var pipelineType = PipelineTypes.Notification.MakeGenericType(notificationType); if (NeedCreatePipeline(services, pipelineType, lifetime)) { services.Add(new ServiceDescriptor( pipelineType, PipelineActivators.GetNotificationPipelineActivator(notificationType), lifetime)); } return(services); }