private void ConfigureCommands()
        {
            services.AddSingleton <ICommandFactory, CommandFactory>();
            services.AddSingleton <ICommandEventsManager, CommandEventsManager>();
            services.AddSingleton <ICommandParser, CommandParser>();
            services.AddSingleton <Func <string, ICommand> >((IServiceProvider serviceProvider) => name =>
            {
                var commandType = CommandTypeResolver.Resolve(name);
                if (commandType == null)
                {
                    return(null);
                }

                return((ICommand)serviceProvider.GetService(commandType));
            });

            foreach (var commandType in CommandTypeResolver.GetCommandTypes())
            {
                services.AddTransient(commandType);
            }
        }
Esempio n. 2
0
 private ResolvedCommand ResolveCommandType(string text)
 {
     return(CommandTypeResolver.Resolve(text));
 }