/// <summary> /// Creates a mediator. /// </summary> /// <param name="serviceProvider">The mediator service provider.</param> /// <param name="middlewaresFactories">The mediator pipeline middlewares.</param> public Mediator(IMediatorServiceProvider serviceProvider) { ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); // The middlewares must be stored internally in reverse order // to ensure optimum performance and proper execution. _middlewares = serviceProvider.GetMiddlewares().Reverse().ToArray(); }
/// <summary> /// Creates a new instance /// </summary> /// <param name="serviceProvider">The handler factory</param> /// <exception cref="ArgumentNullException"></exception> public Mediator(IMediatorServiceProvider serviceProvider) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); }