示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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;
            }
        }