Exemple #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 PageRequestDelegateFactory(
     PageActionInvokerCache cache,
     IModelMetadataProvider modelMetadataProvider,
     ITempDataDictionaryFactory tempDataFactory,
     IOptions<MvcOptions> mvcOptions,
     IOptions<MvcViewOptions> mvcViewOptions,
     IPageHandlerMethodSelector selector,
     DiagnosticListener diagnosticListener,
     ILoggerFactory loggerFactory,
     IActionResultTypeMapper mapper)
     : this(cache, modelMetadataProvider, tempDataFactory, mvcOptions, mvcViewOptions, selector, diagnosticListener, loggerFactory, mapper, null)
 {
 }
        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()));
        }