Esempio n. 1
0
 public PageActionInvokerProvider(
     PageLoader pageLoader,
     PageActionInvokerCache pageActionInvokerCache,
     IModelMetadataProvider modelMetadataProvider,
     ITempDataDictionaryFactory tempDataFactory,
     IOptions <MvcOptions> mvcOptions,
     IOptions <MvcViewOptions> mvcViewOptions,
     IPageHandlerMethodSelector selector,
     DiagnosticListener diagnosticListener,
     ILoggerFactory loggerFactory,
     IActionResultTypeMapper mapper,
     IActionContextAccessor actionContextAccessor = null)
 {
     _pageLoader             = pageLoader;
     _pageActionInvokerCache = pageActionInvokerCache;
     _valueProviderFactories = mvcOptions.Value.ValueProviderFactories.ToArray();
     _modelMetadataProvider  = modelMetadataProvider;
     _tempDataFactory        = tempDataFactory;
     _mvcViewOptions         = mvcViewOptions.Value;
     _selector              = selector;
     _diagnosticListener    = diagnosticListener;
     _logger                = loggerFactory.CreateLogger <PageActionInvoker>();
     _mapper                = mapper;
     _actionContextAccessor = actionContextAccessor ?? ActionContextAccessor.Null;
 }
        public PageLoaderMatcherPolicy(PageLoader loader)
        {
            if (loader == null)
            {
                throw new ArgumentNullException(nameof(loader));
            }

            _loader = loader;
        }
Esempio n. 3
0
        public DynamicPageEndpointMatcherPolicy(DynamicPageEndpointSelector selector, PageLoader loader)
        {
            if (selector == null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

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

            _selector = selector;
            _loader   = loader;
        }
        private static PageActionInvokerProvider CreateInvokerProvider(
            PageLoader loader,
            IPageFactoryProvider pageProvider                  = null,
            IPageModelFactoryProvider modelProvider            = null,
            IRazorPageFactoryProvider razorPageFactoryProvider = null,
            MvcOptions mvcOptions = null)
        {
            var tempDataFactory = new Mock <ITempDataDictionaryFactory>();

            tempDataFactory
            .Setup(t => t.GetTempData(It.IsAny <HttpContext>()))
            .Returns((HttpContext context) => new TempDataDictionary(context, Mock.Of <ITempDataProvider>()));

            var modelMetadataProvider = TestModelMetadataProvider.CreateDefaultProvider();
            var modelBinderFactory    = TestModelBinderFactory.CreateDefault();

            mvcOptions = mvcOptions ?? new MvcOptions();

            var parameterBinder = new ParameterBinder(
                modelMetadataProvider,
                TestModelBinderFactory.CreateDefault(),
                Mock.Of <IObjectModelValidator>(),
                Options.Create(mvcOptions),
                NullLoggerFactory.Instance);

            var cache = new PageActionInvokerCache(
                pageProvider ?? Mock.Of <IPageFactoryProvider>(),
                modelProvider ?? Mock.Of <IPageModelFactoryProvider>(),
                razorPageFactoryProvider ?? Mock.Of <IRazorPageFactoryProvider>(),
                new IFilterProvider[0],
                parameterBinder,
                modelMetadataProvider,
                modelBinderFactory,
                Options.Create(mvcOptions));

            return(new PageActionInvokerProvider(
                       loader,
                       cache,
                       modelMetadataProvider,
                       tempDataFactory.Object,
                       Options.Create(mvcOptions),
                       Options.Create(new MvcViewOptions()),
                       Mock.Of <IPageHandlerMethodSelector>(),
                       new DiagnosticListener("Microsoft.AspNetCore"),
                       NullLoggerFactory.Instance,
                       new ActionResultTypeMapper()));
        }
        public DynamicPageEndpointMatcherPolicy(DynamicPageEndpointSelectorCache selectorCache, PageLoader loader, EndpointMetadataComparer comparer)
        {
            if (selectorCache == null)
            {
                throw new ArgumentNullException(nameof(selectorCache));
            }

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

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

            _selectorCache = selectorCache;
            _loader        = loader;
            _comparer      = comparer;
        }
 public PageActionInvokerProvider(
     PageLoader loader,
     IPageFactoryProvider pageFactoryProvider,
     IPageModelFactoryProvider modelFactoryProvider,
     IRazorPageFactoryProvider razorPageFactoryProvider,
     IActionDescriptorCollectionProvider collectionProvider,
     IEnumerable <IFilterProvider> filterProviders,
     ParameterBinder parameterBinder,
     IModelMetadataProvider modelMetadataProvider,
     IModelBinderFactory modelBinderFactory,
     ITempDataDictionaryFactory tempDataFactory,
     IOptions <MvcOptions> mvcOptions,
     IOptions <HtmlHelperOptions> htmlHelperOptions,
     IPageHandlerMethodSelector selector,
     DiagnosticListener diagnosticListener,
     ILoggerFactory loggerFactory,
     IActionResultTypeMapper mapper,
     IActionContextAccessor actionContextAccessor)
 {
     _loader = loader;
     _pageFactoryProvider      = pageFactoryProvider;
     _modelFactoryProvider     = modelFactoryProvider;
     _modelBinderFactory       = modelBinderFactory;
     _razorPageFactoryProvider = razorPageFactoryProvider;
     _collectionProvider       = collectionProvider;
     _filterProviders          = filterProviders.ToArray();
     _valueProviderFactories   = mvcOptions.Value.ValueProviderFactories.ToArray();
     _parameterBinder          = parameterBinder;
     _modelMetadataProvider    = modelMetadataProvider;
     _tempDataFactory          = tempDataFactory;
     _mvcOptions            = mvcOptions.Value;
     _htmlHelperOptions     = htmlHelperOptions.Value;
     _selector              = selector;
     _diagnosticListener    = diagnosticListener;
     _logger                = loggerFactory.CreateLogger <PageActionInvoker>();
     _mapper                = mapper;
     _actionContextAccessor = actionContextAccessor ?? ActionContextAccessor.Null;
 }
 public PageActionInvokerProvider(
     PageLoader loader,
     IPageFactoryProvider pageFactoryProvider,
     IPageModelFactoryProvider modelFactoryProvider,
     IRazorPageFactoryProvider razorPageFactoryProvider,
     IActionDescriptorCollectionProvider collectionProvider,
     IEnumerable <IFilterProvider> filterProviders,
     ParameterBinder parameterBinder,
     IModelMetadataProvider modelMetadataProvider,
     IModelBinderFactory modelBinderFactory,
     ITempDataDictionaryFactory tempDataFactory,
     IOptions <MvcOptions> mvcOptions,
     IOptions <HtmlHelperOptions> htmlHelperOptions,
     IPageHandlerMethodSelector selector,
     DiagnosticListener diagnosticListener,
     ILoggerFactory loggerFactory,
     IActionResultTypeMapper mapper)
     : this(
         loader,
         pageFactoryProvider,
         modelFactoryProvider,
         razorPageFactoryProvider,
         collectionProvider,
         filterProviders,
         parameterBinder,
         modelMetadataProvider,
         modelBinderFactory,
         tempDataFactory,
         mvcOptions,
         htmlHelperOptions,
         selector,
         diagnosticListener,
         loggerFactory,
         mapper,
         actionContextAccessor : null)
 {
 }