Пример #1
0
        public IGameBuilder AddCommand(Type commandType)
        {
            if (!typeof(ICommand).IsAssignableFrom(commandType))
            {
                throw new ArgumentException("Command type is not assignable from ICommand");
            }

            var commandName = commandType.GetCommandName();

            _commands.Add(commandName, commandType);

            if (commandType.GetCustomAttribute <GlobalAttribute>() != null)
            {
                _globalCommands.Add(commandName, commandType);
            }

            _serviceCollection.AddScoped(commandType);
            return(this);
        }