public static IServiceCollection AddCommandHandlingDependencies <T, TResult>(this IServiceCollection collection)
        {
            CommandHandlerTypeStorage <T, TResult> .Initialize();

            var types = CommandHandlerTypeStorage <T, TResult> .GetAll();

            foreach (var type in types)
            {
                collection.AddTransient(type);
            }

            collection.AddTransient <ICommandHandlerFactory <T, TResult>, CommandHandlerFactory <T, TResult> >();

            return(collection);
        }
Пример #2
0
 public IContextCommandHandler <T, TResult> GetByContextStatus(string status)
 {
     return(_serviceProvider.GetRequiredService(CommandHandlerTypeStorage <T, TResult> .GetByStatus(status)) as
            IContextCommandHandler <T, TResult>);
 }
Пример #3
0
 public ICommandHandler <T, TResult> GetByCommand(string command)
 {
     return(_serviceProvider.GetRequiredService(CommandHandlerTypeStorage <T, TResult> .GetByCommand(command)) as ICommandHandler <T, TResult>);
 }