public DisplayForTagHelper(IModelMetadataProvider modelMetadataProvider, ICompositeViewEngine viewEngine,
                            IViewBufferScope viewBufferScope)
 {
     _modelMetadataProvider = modelMetadataProvider;
     _viewEngine            = viewEngine;
     _viewBufferScope       = viewBufferScope;
 }
Exemple #2
0
 /// <summary>
 /// Creates a new <see cref="PartialTagHelper"/>.
 /// </summary>
 /// <param name="viewEngine">The <see cref="ICompositeViewEngine"/> used to locate the partial view.</param>
 /// <param name="viewBufferScope">The <see cref="IViewBufferScope"/>.</param>
 public PartialTagHelper(
     ICompositeViewEngine viewEngine,
     IViewBufferScope viewBufferScope)
 {
     _viewEngine      = viewEngine ?? throw new ArgumentNullException(nameof(viewEngine));
     _viewBufferScope = viewBufferScope ?? throw new ArgumentNullException(nameof(viewBufferScope));
 }
Exemple #3
0
 public SafeMemoryPoolViewBufferScope(ArrayPool <ViewBufferValue> viewBufferPool, ArrayPool <char> charPool, IHttpContextAccessor contextAccessor)
 {
     this.viewBufferPool  = viewBufferPool;
     this.charPool        = charPool;
     scopedBuffer         = new MemoryPoolViewBufferScope(viewBufferPool, charPool);
     this.contextAccessor = contextAccessor;;
 }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlHelper{TModel}"/> class.
        /// </summary>
        public HtmlHelper(
            IHtmlGenerator htmlGenerator,
            ICompositeViewEngine viewEngine,
            IModelMetadataProvider metadataProvider,
#pragma warning disable PUB0001 // Pubternal type in public API
            IViewBufferScope bufferScope,
#pragma warning restore PUB0001
            HtmlEncoder htmlEncoder,
            UrlEncoder urlEncoder,
#pragma warning disable PUB0001 // Pubternal type in public API
            ExpressionTextCache expressionTextCache
#pragma warning restore PUB0001
            )
            : base(
                htmlGenerator,
                viewEngine,
                metadataProvider,
                bufferScope,
                htmlEncoder,
                urlEncoder)
        {
            if (expressionTextCache == null)
            {
                throw new ArgumentNullException(nameof(expressionTextCache));
            }

            _expressionTextCache = expressionTextCache;
        }
        public TemplateRenderer(
            IViewEngine viewEngine,
            IViewBufferScope bufferScope,
            ViewContext viewContext,
            ViewDataDictionary viewData,
            string templateName,
            bool readOnly)
        {
            if (viewEngine == null)
            {
                throw new ArgumentNullException(nameof(viewEngine));
            }

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

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

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

            _viewEngine = viewEngine;
            _bufferScope = bufferScope;
            _viewContext = viewContext;
            _viewData = viewData;
            _templateName = templateName;
            _readOnly = readOnly;
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TemplateService"/> class.
 /// </summary>
 /// <param name="viewEngine">The view engine.</param>
 /// <param name="bufferScope">The buffer scope.</param>
 /// <param name="templateProvider">The template provider.</param>
 public TemplateService(
     ICompositeViewEngine viewEngine,
     IViewBufferScope bufferScope,
     ITemplateProvider templateProvider)
     : this((IViewEngine)viewEngine, bufferScope, templateProvider)
 {
 }
        public TemplateRenderer(
            IViewEngine viewEngine,
            IViewBufferScope bufferScope,
            ViewContext viewContext,
            ViewDataDictionary viewData,
            string templateName,
            bool readOnly)
        {
            if (viewEngine == null)
            {
                throw new ArgumentNullException(nameof(viewEngine));
            }

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

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

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

            _viewEngine   = viewEngine;
            _bufferScope  = bufferScope;
            _viewContext  = viewContext;
            _viewData     = viewData;
            _templateName = templateName;
            _readOnly     = readOnly;
        }
 public SampleTagHelper(
     ICompositeViewEngine viewEngine,
     IViewBufferScope viewBufferScope) : base(viewEngine, viewBufferScope)
 {
     Model = this;
     Name  = "_Sample";
 }
Exemple #9
0
 /// <summary>
 /// Returns an empty <see cref="IHtmlContent"/>
 /// </summary>
 /// <param name="templateService">The template service. This parameter is not used.</param>
 /// <param name="bufferScope">The buffer scope. This parameter is not used.</param>
 /// <param name="viewContext">The view context. This parameter is not used.</param>
 public IHtmlContent Render(
     ITemplateService templateService,
     IViewBufferScope bufferScope,
     ViewContext viewContext)
 {
     return(HtmlString.Empty);
 }
Exemple #10
0
 public HomeController(IUserService userService, ILoggerFactory loggerFactory, ILogger <HomeController> logger, IViewBufferScope viewBufferScope, IOpenGenericService <ClosedGenericTypeParameter> closedGenericService)
 {
     this.logger               = logger ?? throw new ArgumentNullException(nameof(logger));
     this.userService          = userService ?? throw new ArgumentNullException(nameof(userService));
     this.loggerFactory        = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.viewBufferScope      = viewBufferScope ?? throw new ArgumentNullException(nameof(viewBufferScope));
     this.closedGenericService = closedGenericService;
 }
 public ModalPartialTagHelper(ICompositeViewEngine viewEngine, IViewBufferScope viewBufferScope)
 {
     _inner = new PartialTagHelper(viewEngine, viewBufferScope)
     {
         Name  = "_Modal",
         Model = _model,
     };
 }
Exemple #12
0
 public ComponentRenderer(
     StaticComponentRenderer staticComponentRenderer,
     ServerComponentSerializer serverComponentSerializer,
     IViewBufferScope viewBufferScope)
 {
     _staticComponentRenderer   = staticComponentRenderer;
     _serverComponentSerializer = serverComponentSerializer;
     _viewBufferScope           = viewBufferScope;
 }
 public TemplateRenderer(
     IEngineHandler engineHandler,
     HtmlEncoder htmlEncoder,
     IViewBufferScope bufferScope)
 {
     _engineHandler = engineHandler ?? throw new ArgumentNullException(nameof(engineHandler));
     _bufferScope   = bufferScope ?? throw new ArgumentNullException(nameof(bufferScope));
     _htmlEncoder   = htmlEncoder ?? throw new ArgumentNullException(nameof(htmlEncoder));
 }
Exemple #14
0
        private List <ViewBufferPage> fMultiplePages; // Allocated only if necessary

        public ViewBuffer(IViewBufferScope bufferScope, string name, int pageSize)
        {
            TkDebug.AssertArgumentNull(bufferScope, nameof(bufferScope), null);
            TkDebug.AssertArgument(pageSize > 0, nameof(pageSize), $"{nameof(pageSize)}必须大于0", null);

            fBufferScope = bufferScope;
            fName        = name;
            fPageSize    = pageSize;
        }
Exemple #15
0
 public PartialInvoker(
     IViewBufferScope viewBufferScope,
     ICompositeViewEngine viewEngine,
     IMemoryCache memoryCache)
 {
     _memoryCache     = memoryCache ?? throw new ArgumentNullException(nameof(memoryCache));
     _viewEngine      = viewEngine ?? throw new ArgumentNullException(nameof(viewEngine));
     _viewBufferScope = viewBufferScope ?? throw new ArgumentNullException(nameof(viewBufferScope));
 }
Exemple #16
0
        public PageRenderer(TemplatePage page, IPageLookup pageLookup)
        {
            this.razorPage  = page;
            this.pageLookup = pageLookup;

            _htmlEncoder       = HtmlEncoder.Default;
            _bufferScope       = new MemoryPoolViewBufferScope();
            ViewStartPages     = new List <TemplatePage>();
            PreRenderCallbacks = new PreRenderActionList();
        }
Exemple #17
0
        /// <summary>
        /// Initializes a new instance of <see cref="ViewBuffer"/>.
        /// </summary>
        /// <param name="bufferScope">The <see cref="IViewBufferScope"/>.</param>
        /// <param name="name">A name to identify this instance.</param>
        public ViewBuffer(IViewBufferScope bufferScope, string name)
        {
            if (bufferScope == null)
            {
                throw new ArgumentNullException(nameof(bufferScope));
            }

            _bufferScope = bufferScope;
            _name = name;
        }
Exemple #18
0
        /// <summary>
        /// Initializes a new instance of <see cref="ViewBuffer"/>.
        /// </summary>
        /// <param name="bufferScope">The <see cref="IViewBufferScope"/>.</param>
        /// <param name="name">A name to identify this instance.</param>
        public ViewBuffer(IViewBufferScope bufferScope, string name)
        {
            if (bufferScope == null)
            {
                throw new ArgumentNullException(nameof(bufferScope));
            }

            _bufferScope = bufferScope;
            _name        = name;
        }
Exemple #19
0
 public HtmlHelperGeneratorService(IHtmlGenerator htmlGenerator, ICompositeViewEngine compositeViewEngine, IModelMetadataProvider modelMetadataProvider, IViewBufferScope viewBufferScope, IActionContextAccessor actionContextAccessor, ITempDataProvider tempDataProvider, IOptions <MvcViewOptions> options)
 {
     _htmlGenerator         = htmlGenerator;
     _compositeViewEngine   = compositeViewEngine;
     _modelMetadataProvider = modelMetadataProvider;
     _viewBufferScope       = viewBufferScope;
     _actionContextAccessor = actionContextAccessor;
     _tempDataProvider      = tempDataProvider;
     _htmlHelperOptions     = options.Value.HtmlHelperOptions;
 }
        public PartialTagHelper(
            ICompositeViewEngine viewEngine,
#pragma warning disable PUB0001 // Pubternal type in public API
            IViewBufferScope viewBufferScope
#pragma warning restore PUB0001
            )
        {
            _viewEngine      = viewEngine ?? throw new ArgumentNullException(nameof(viewEngine));
            _viewBufferScope = viewBufferScope ?? throw new ArgumentNullException(nameof(viewBufferScope));
        }
Exemple #21
0
 public DataPartialTagHelper(
     IModelService modelService,
     IPageRepository pageRepository,
     ICompositeViewEngine viewEngine,
     IViewBufferScope viewBufferScope)
 {
     _modelService    = modelService;
     _pageRepository  = pageRepository;
     _viewEngine      = viewEngine;
     _viewBufferScope = viewBufferScope;
 }
Exemple #22
0
        internal TemplateRenderer(IEngineHandler engineHandler,
                                  HtmlEncoder htmlEncoder, IViewBufferScope bufferScope)
        {
            TkDebug.AssertArgumentNull(engineHandler, nameof(engineHandler), null);
            TkDebug.AssertArgumentNull(bufferScope, nameof(bufferScope), null);
            TkDebug.AssertArgumentNull(htmlEncoder, nameof(htmlEncoder), null);

            fEngineHandler = engineHandler;
            fBufferScope   = bufferScope;
            fHtmlEncoder   = htmlEncoder;
        }
 public ViewTemplateTests()
 {
     _view            = new Mock <IView>(MockBehavior.Strict);
     _viewName        = Guid.NewGuid().ToString();
     _template        = new ViewTemplate(_view.Object, _viewName);
     _templateService = new Mock <ITemplateService>(MockBehavior.Strict);
     _bufferScope     = new MemoryPoolViewBufferScope(
         ArrayPool <ViewBufferValue> .Shared,
         ArrayPool <char> .Shared);
     _viewContext = new TestViewContext <TestModel>();
 }
Exemple #24
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

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

            output.SuppressOutput();

            Dictionary <string, object> htmlAttributes = new Dictionary <string, object>();

            if (IsDisabled)
            {
                htmlAttributes.Add("disabled", "disabled");
            }

            if (IsRequired)
            {
                output.PreElement.SetHtmlContent("<div class='input-group input-group-required'>");
                output.PostElement.SetHtmlContent("<div class=\"input-group-btn\"><span class=\"required\">*</span></div></div>");
            }

            IViewContextAware viewContextAware = _htmlHelper as IViewContextAware;

            viewContextAware?.Contextualize(ViewContext);

            bool.TryParse(RenderFormControlClass, out bool renderFormControlClass);
            if ((string.IsNullOrEmpty(RenderFormControlClass) && For.Metadata.ModelType.Name.Equals("String")) || renderFormControlClass)
            {
                htmlAttributes.Add("class", "form-control");
            }

            IViewEngine      viewEngine      = CoreUtility.GetPrivateFieldValue(_htmlHelper, "_viewEngine") as IViewEngine;
            IViewBufferScope bufferScope     = CoreUtility.GetPrivateFieldValue(_htmlHelper, "_bufferScope") as IViewBufferScope;
            TemplateBuilder  templateBuilder = new TemplateBuilder(
                viewEngine,
                bufferScope,
                _htmlHelper.ViewContext,
                _htmlHelper.ViewData,
                For.ModelExplorer,
                For.Name,
                Template,
                readOnly: false,
                additionalViewData: new { htmlAttributes, postfix = Postfix });

            IHtmlContent htmlOutput = templateBuilder.Build();

            output.Content.SetHtmlContent(htmlOutput.ToHtmlString());
        }
Exemple #25
0
 public TemplateRenderer(
     ITemplatePage razorPage,
     IRazorLightEngine razorEngine,
     HtmlEncoder htmlEncoder,
     IViewBufferScope bufferScope)
 {
     RazorPage    = razorPage ?? throw new ArgumentNullException(nameof(razorPage));
     _engine      = razorEngine ?? throw new ArgumentNullException(nameof(razorEngine));
     _bufferScope = bufferScope ?? throw new ArgumentNullException(nameof(bufferScope));
     _htmlEncoder = htmlEncoder ?? throw new ArgumentNullException(nameof(htmlEncoder));
 }
 /// <summary>
 /// Create.
 /// </summary>
 public ActionExecutionHtmlHelper(
     IHtmlGenerator htmlGenerator,
     ICompositeViewEngine viewEngine,
     IModelMetadataProvider metadataProvider,
     IViewBufferScope bufferScope,
     HtmlEncoder htmlEncoder,
     UrlEncoder urlEncoder,
     ModelExpressionProvider modelExpressionProvider)
     : base(htmlGenerator, viewEngine, metadataProvider, bufferScope, htmlEncoder, urlEncoder, modelExpressionProvider)
 {
 }
Exemple #27
0
        public CodeTemplateTestsBase()
        {
            _template        = new Lazy <TTemplate>(CreateTemplate);
            _templateService = Mock.Of <ITemplateService>(MockBehavior.Strict);
            _bufferScope     = Mock.Of <IViewBufferScope>(MockBehavior.Strict);
            _requestServices = new Mock <IServiceProvider>(MockBehavior.Strict);
            _htmlHelper      = new Mock <IHtmlHelper>(MockBehavior.Strict);

            _requestServices.Setup(m => m.GetService(typeof(IHtmlHelper)))
            .Returns(_htmlHelper.Object)
            .Verifiable();
        }
        /// <summary>
        /// Renders this template for the given <paramref name="viewContext" />
        /// </summary>
        /// <param name="templateService">The template service.</param>
        /// <param name="bufferScope">The buffer scope. This parameter is not used.</param>
        /// <param name="viewContext">The view context.</param>
        public IHtmlContent Render(
            ITemplateService templateService,
            IViewBufferScope bufferScope,
            ViewContext viewContext)
        {
            Guard.NotNull(templateService, nameof(templateService));
            Guard.NotNull(viewContext, nameof(viewContext));

            var helper = CreateHtmlHelper(viewContext);

            return(Render(helper, templateService));
        }
Exemple #29
0
        /// <inheritdoc />
        public virtual async Task RenderAsync(ViewContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _bufferScope = context.HttpContext.RequestServices.GetRequiredService <IViewBufferScope>();
            var bodyWriter = await RenderPageAsync(RazorPage, context, invokeViewStarts : true);

            await RenderLayoutAsync(context, bodyWriter);
        }
Exemple #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HtmlHelper"/> class.
        /// </summary>
        public HtmlHelper(
            IHtmlGenerator htmlGenerator,
            ICompositeViewEngine viewEngine,
            IModelMetadataProvider metadataProvider,
            IViewBufferScope bufferScope,
            HtmlEncoder htmlEncoder,
            UrlEncoder urlEncoder,
            JavaScriptEncoder javaScriptEncoder)
        {
            if (htmlGenerator == null)
            {
                throw new ArgumentNullException(nameof(htmlGenerator));
            }

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

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

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

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

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

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

            _viewEngine       = viewEngine;
            _htmlGenerator    = htmlGenerator;
            _htmlEncoder      = htmlEncoder;
            _bufferScope      = bufferScope;
            MetadataProvider  = metadataProvider;
            UrlEncoder        = urlEncoder;
            JavaScriptEncoder = javaScriptEncoder;
        }
Exemple #31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TemplateService"/> class.
        /// </summary>
        /// <param name="viewEngine">The view engine.</param>
        /// <param name="bufferScope">The buffer scope.</param>
        /// <param name="templateProvider">The template provider.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="viewEngine"/>,
        /// <paramref name="bufferScope"/>
        /// or
        /// <paramref name="templateProvider"/>
        /// </exception>
        public TemplateService(
            IViewEngine viewEngine,
            IViewBufferScope bufferScope,
            ITemplateProvider templateProvider)
        {
            Guard.NotNull(viewEngine, nameof(viewEngine));
            Guard.NotNull(bufferScope, nameof(bufferScope));
            Guard.NotNull(templateProvider, nameof(templateProvider));

            _viewEngine       = viewEngine;
            _bufferScope      = bufferScope;
            _templateProvider = templateProvider;
        }
Exemple #32
0
 private void ensureCreated()
 {
     if (scopedBuffer == null)
     {
         var buffer = contextAccessor.HttpContext.RequestServices.GetService(typeof(IViewBufferScope)) as SafeMemoryPoolViewBufferScope;
         if (buffer == null)
         {
             return;
         }
         scopedBuffer = buffer.scopedBuffer;
         buffer.addObjectToDispose(this);
     }
 }
        public TemplateBuilder(
            IViewEngine viewEngine,
            IViewBufferScope bufferScope,
            ViewContext viewContext,
            ViewDataDictionary viewData,
            ModelExplorer modelExplorer,
            string htmlFieldName,
            string templateName,
            bool readOnly,
            object additionalViewData)
        {
            if (viewEngine == null)
            {
                throw new ArgumentNullException(nameof(viewEngine));
            }

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

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

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

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

            _viewEngine = viewEngine;
            _bufferScope = bufferScope;
            _viewContext = viewContext;
            _viewData = viewData;
            _modelExplorer = modelExplorer;
            _htmlFieldName = htmlFieldName;
            _templateName = templateName;
            _readOnly = readOnly;
            _additionalViewData = additionalViewData;

            _model = modelExplorer.Model;
            _metadata = modelExplorer.Metadata;
        }
        /// <summary>
        /// Initializes a new instance of <see cref="DefaultViewComponentHelper"/>.
        /// </summary>
        /// <param name="descriptorProvider">The <see cref="IViewComponentDescriptorCollectionProvider"/>
        /// used to locate view components.</param>
        /// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param>
        /// <param name="selector">The <see cref="IViewComponentSelector"/>.</param>
        /// <param name="invokerFactory">The <see cref="IViewComponentInvokerFactory"/>.</param>
        /// <param name="viewBufferScope">The <see cref="IViewBufferScope"/> that manages the lifetime of
        /// <see cref="ViewBuffer"/> instances.</param>
        public DefaultViewComponentHelper(
            IViewComponentDescriptorCollectionProvider descriptorProvider,
            HtmlEncoder htmlEncoder,
            IViewComponentSelector selector,
            IViewComponentInvokerFactory invokerFactory,
            IViewBufferScope viewBufferScope)
        {
            if (descriptorProvider == null)
            {
                throw new ArgumentNullException(nameof(descriptorProvider));
            }

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

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

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

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

            _descriptorProvider = descriptorProvider;
            _htmlEncoder = htmlEncoder;
            _selector = selector;
            _invokerFactory = invokerFactory;
            _viewBufferScope = viewBufferScope;
        }
Exemple #35
0
        /// <inheritdoc />
        public virtual async Task RenderAsync(ViewContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // This GetRequiredService call is by design. ViewBufferScope is a scoped service, RazorViewEngine
            // is the component responsible for creating RazorViews and it is a Singleton service. It doesn't
            // have access to the RequestServices so requiring the service when we render the page is the best
            // we can do.
            _bufferScope = context.HttpContext.RequestServices.GetRequiredService<IViewBufferScope>();
            var bodyWriter = await RenderPageAsync(RazorPage, context, invokeViewStarts: true);
            await RenderLayoutAsync(context, bodyWriter);
        }
Exemple #36
0
        /// <inheritdoc />
        public virtual async Task RenderAsync(ViewContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _bufferScope = context.HttpContext.RequestServices.GetRequiredService<IViewBufferScope>();
            var bodyWriter = await RenderPageAsync(RazorPage, context, invokeViewStarts: true);
            await RenderLayoutAsync(context, bodyWriter);
        }
Exemple #37
0
        private static ViewContext CreateViewContext(
            TextWriter writer = null,
            IViewBufferScope bufferScope = null,
            string viewPath = null)
        {
            bufferScope = bufferScope ?? new TestViewBufferScope();
            var buffer = new ViewBuffer(bufferScope, viewPath ?? "TEST", 32);
            writer = writer ?? new ViewBufferTextWriter(buffer, Encoding.UTF8);

            var httpContext = new DefaultHttpContext();
            var serviceProvider = new ServiceCollection()
                .AddSingleton<IViewBufferScope>(bufferScope)
                .BuildServiceProvider();
            httpContext.RequestServices = serviceProvider;
            var actionContext = new ActionContext(
                httpContext,
                new RouteData(),
                new ActionDescriptor());
            var viewMock = new Mock<IView>();
            if (!string.IsNullOrEmpty(viewPath))
            {
                viewMock.Setup(v => v.Path).Returns(viewPath);
            }
            return new ViewContext(
                actionContext,
                viewMock.Object,
                new ViewDataDictionary(new EmptyModelMetadataProvider()),
                Mock.Of<ITempDataDictionary>(),
                writer,
                new HtmlHelperOptions());
        }