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); }
public IContextCommandHandler <T, TResult> GetByContextStatus(string status) { return(_serviceProvider.GetRequiredService(CommandHandlerTypeStorage <T, TResult> .GetByStatus(status)) as IContextCommandHandler <T, TResult>); }
public ICommandHandler <T, TResult> GetByCommand(string command) { return(_serviceProvider.GetRequiredService(CommandHandlerTypeStorage <T, TResult> .GetByCommand(command)) as ICommandHandler <T, TResult>); }