Ejemplo n.º 1
0
        public FilterActionInvoker(
            ActionContext actionContext,
            ControllerActionInvokerCache controllerActionInvokerCache,
            IReadOnlyList <IInputFormatter> inputFormatters,
            IReadOnlyList <IModelValidatorProvider> modelValidatorProviders,
            IReadOnlyList <IValueProviderFactory> valueProviderFactories,
            ILogger logger,
            DiagnosticSource diagnosticSource,
            int maxModelValidationErrors)
        {
            if (actionContext == null)
            {
                throw new ArgumentNullException(nameof(actionContext));
            }

            if (controllerActionInvokerCache == null)
            {
                throw new ArgumentNullException(nameof(controllerActionInvokerCache));
            }

            if (inputFormatters == null)
            {
                throw new ArgumentNullException(nameof(inputFormatters));
            }

            if (modelValidatorProviders == null)
            {
                throw new ArgumentNullException(nameof(modelValidatorProviders));
            }

            if (valueProviderFactories == null)
            {
                throw new ArgumentNullException(nameof(valueProviderFactories));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (diagnosticSource == null)
            {
                throw new ArgumentNullException(nameof(diagnosticSource));
            }

            Context = new ControllerContext(actionContext);

            _controllerActionInvokerCache = controllerActionInvokerCache;
            _inputFormatters         = inputFormatters;
            _modelValidatorProviders = modelValidatorProviders;
            _valueProviderFactories  = valueProviderFactories;
            Logger                    = logger;
            _diagnosticSource         = diagnosticSource;
            _maxModelValidationErrors = maxModelValidationErrors;
        }
Ejemplo n.º 2
0
 public ControllerActionInvokerProvider(
     ControllerActionInvokerCache controllerActionInvokerCache,
     IOptions <MvcOptions> optionsAccessor,
     ILoggerFactory loggerFactory,
     DiagnosticSource diagnosticSource)
 {
     _controllerActionInvokerCache = controllerActionInvokerCache;
     _valueProviderFactories       = optionsAccessor.Value.ValueProviderFactories.ToArray();
     _maxModelValidationErrors     = optionsAccessor.Value.MaxModelValidationErrors;
     _logger           = loggerFactory.CreateLogger <ControllerActionInvoker>();
     _diagnosticSource = diagnosticSource;
 }
        public ControllerActionInvoker(
            ActionContext actionContext,
            ControllerActionInvokerCache controllerActionInvokerCache,
            IControllerFactory controllerFactory,
            ControllerActionDescriptor descriptor,
            IReadOnlyList <IInputFormatter> inputFormatters,
            IControllerActionArgumentBinder argumentBinder,
            IReadOnlyList <IModelBinder> modelBinders,
            IReadOnlyList <IModelValidatorProvider> modelValidatorProviders,
            IReadOnlyList <IValueProviderFactory> valueProviderFactories,
            ILogger logger,
            DiagnosticSource diagnosticSource,
            int maxModelValidationErrors)
            : base(
                actionContext,
                controllerActionInvokerCache,
                inputFormatters,
                modelBinders,
                modelValidatorProviders,
                valueProviderFactories,
                logger,
                diagnosticSource,
                maxModelValidationErrors)
        {
            if (controllerFactory == null)
            {
                throw new ArgumentNullException(nameof(controllerFactory));
            }

            if (descriptor == null)
            {
                throw new ArgumentNullException(nameof(descriptor));
            }

            if (argumentBinder == null)
            {
                throw new ArgumentNullException(nameof(argumentBinder));
            }

            _controllerFactory = controllerFactory;
            _descriptor        = descriptor;
            _argumentBinder    = argumentBinder;

            if (descriptor.MethodInfo == null)
            {
                throw new ArgumentException(
                          Resources.FormatPropertyOfTypeCannotBeNull(
                              nameof(descriptor.MethodInfo),
                              typeof(ControllerActionDescriptor)),
                          nameof(descriptor));
            }
        }
Ejemplo n.º 4
0
 public ControllerActionInvokerProvider(
     IControllerFactory controllerFactory,
     ControllerActionInvokerCache controllerActionInvokerCache,
     IControllerActionArgumentBinder argumentBinder,
     IOptions <MvcOptions> optionsAccessor,
     ILoggerFactory loggerFactory,
     DiagnosticSource diagnosticSource)
 {
     _controllerFactory            = controllerFactory;
     _controllerActionInvokerCache = controllerActionInvokerCache;
     _argumentBinder           = argumentBinder;
     _inputFormatters          = optionsAccessor.Value.InputFormatters.ToArray();
     _valueProviderFactories   = optionsAccessor.Value.ValueProviderFactories.ToArray();
     _maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors;
     _logger           = loggerFactory.CreateLogger <ControllerActionInvoker>();
     _diagnosticSource = diagnosticSource;
 }
Ejemplo n.º 5
0
        public ControllerActionInvoker(
            ControllerActionInvokerCache cache,
            IControllerFactory controllerFactory,
            IControllerArgumentBinder controllerArgumentBinder,
            ILogger logger,
            DiagnosticSource diagnosticSource,
            ActionContext actionContext,
            IReadOnlyList <IValueProviderFactory> valueProviderFactories,
            int maxModelValidationErrors)
        {
            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }

            if (controllerFactory == null)
            {
                throw new ArgumentNullException(nameof(controllerFactory));
            }

            if (controllerArgumentBinder == null)
            {
                throw new ArgumentNullException(nameof(controllerArgumentBinder));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            if (diagnosticSource == null)
            {
                throw new ArgumentNullException(nameof(diagnosticSource));
            }

            if (actionContext == null)
            {
                throw new ArgumentNullException(nameof(actionContext));
            }

            if (valueProviderFactories == null)
            {
                throw new ArgumentNullException(nameof(valueProviderFactories));
            }

            _controllerFactory        = controllerFactory;
            _controllerArgumentBinder = controllerArgumentBinder;
            _logger           = logger;
            _diagnosticSource = diagnosticSource;

            _controllerContext = new ControllerContext(actionContext);
            _controllerContext.ModelState.MaxAllowedErrors = maxModelValidationErrors;

            // PERF: These are rarely going to be changed, so let's go copy-on-write.
            _controllerContext.ValueProviderFactories = new CopyOnWriteList <IValueProviderFactory>(valueProviderFactories);

            var cacheEntry = cache.GetState(_controllerContext);

            _filters  = cacheEntry.Filters;
            _executor = cacheEntry.ActionMethodExecutor;
            _cursor   = new FilterCursor(_filters);
        }