/// <summary> /// Initializes a new instance of the <see cref="CommandService"/> class. /// </summary> /// <param name="serviceProvider">The service provider to use to instantiate commands.</param> public CommandService(IServiceProvider?serviceProvider) { _serviceProvider = serviceProvider; _transientCommands = new Dictionary <string, Type>(); _singletonCommands = new Dictionary <string, ICommand>(); _processors = new List <IProcessorStep>(); _compositeProcessor = ProcessCommand; }
private void ComposeProcessor() { NextProcessorDel processor = ProcessCommand; // Include the additional processors by starting with the final processor and building // an invocation chain in reverse. for (var i = _processors.Count - 1; i >= 0; i--) { var nextProcessor = processor; var preprocessor = _processors[i]; processor = context => preprocessor.Process(context, nextProcessor); } _compositeProcessor = processor; }