private void AddIocSubscribe <TCommand, THandler>(IocTypes types = IocTypes.Scoped) where TCommand : Command where THandler : ICommandHandler <TCommand> { var command = typeof(ICommandHandler <TCommand>); var handler = typeof(THandler); AddIoc(command, handler); }
private void AddIocResult <TCommand, TCommandResult, THandler>(IocTypes types = IocTypes.Scoped) where TCommand : Command <TCommandResult> where THandler : ICommandHandler <TCommand, TCommandResult> { var command = typeof(ICommandHandler <TCommand, TCommandResult>); var handler = typeof(THandler); AddIoc(command, handler); }
private void AddIoc(Type command, Type handler, IocTypes types = IocTypes.Scoped) { switch (types) { case IocTypes.Scoped: _serviceCollection.AddScoped(command, handler); break; case IocTypes.Singleton: _serviceCollection.AddSingleton(command, handler); break; case IocTypes.Transien: _serviceCollection.AddTransient(command, handler); break; } }