Ejemplo n.º 1
0
        /// <summary>
        /// Add a engine.
        /// </summary>
        /// <param name="engine">Engine to add</param>
        /// <exception cref="ArgumentNullException"><c>engine</c> is null.</exception>
        public void Add(IViewEngine engine)
        {
            if (engine == null)
                throw new ArgumentNullException("engine");

            _viewEngines.Add(engine.FileExtension, engine);
        }
Ejemplo n.º 2
0
 private async Task WriteToStream(Stream outputStream, IViewEngine viewEngine, IPageViewDefinition viewDefinition)
 {
     using (var writer = new StreamWriter(outputStream))
     {
         SourceLocation errorLocation = null;
         Exception error = null;
         try
         {
             viewDefinition.Render(viewEngine, writer);
         }
         catch (VeilParserException ex)
         {
             error = ex;
             errorLocation = ex.Location;
         }
         catch (VeilCompilerException ex)
         {
             error = ex;
             errorLocation = ex.Node.Location;
         }
         catch (Exception ex)
         {
             error = ex;
         }
         
         if (error != null)
             await GetErrorPage(writer, error, errorLocation).ConfigureAwait(false);
     }
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="NVelocityViewContextAdapter"/> class.
		/// </summary>
		/// <param name="componentName">Name of the component.</param>
		/// <param name="parentNode">The parent node.</param>
		/// <param name="viewEngine">The view engine.</param>
		/// <param name="renderer">The view renderer.</param>
		public NVelocityViewContextAdapter(String componentName, INode parentNode, IViewEngine viewEngine, IViewRenderer renderer)
		{
			this.componentName = componentName;
			this.parentNode = parentNode;
			this.viewEngine = viewEngine;
			this.renderer = renderer;
		}
Ejemplo n.º 4
0
 public StreamContent CreateContent(IViewEngine viewEngine)
 {
     var memoryStream = new MemoryStream();
     WriteToStream(memoryStream, viewEngine);
     memoryStream.Position = 0;
     return new StreamContent(memoryStream);
 }
Ejemplo n.º 5
0
 public ViewViewComponentResult([NotNull] IViewEngine viewEngine, string viewName,
     ViewDataDictionary viewData)
 {
     _viewEngine = viewEngine;
     ViewName = viewName;
     ViewData = viewData;
 }
Ejemplo n.º 6
0
 private ViewEngineStartupContext CreateViewEngineStartupContext(IViewEngine viewEngine)
 {
     return new ViewEngineStartupContext(
         this.viewCache,
         this.viewLocationCache,
         viewEngine.Extensions);
 }
        public void SetUp()
        {
            _mocks = new MockRepository();
            _output = new StringWriter();

            string viewPath = "MvcContrib.ViewEngines.NVelocity.Tests";

            IDictionary properties = new Hashtable();
            properties["resource.loader"] = "assembly";
            properties["assembly.resource.loader.class"] = "NVelocity.Runtime.Resource.Loader.AssemblyResourceLoader, NVelocity";
            properties["assembly.resource.loader.assembly"] = new List<string>() {GetType().Assembly.FullName};
            properties["master.folder"] = viewPath;
            _viewEngine = new NVelocityViewEngine(properties);

            var httpContext = _mocks.DynamicMock<HttpContextBase>();
            var response = _mocks.DynamicMock<HttpResponseBase>();
            SetupResult.For(httpContext.Response).Return(response);
            SetupResult.For(response.Output).Return(_output);

            var requestContext = new RequestContext(httpContext, new RouteData());
            var controller = _mocks.DynamicMock<ControllerBase>();

            _mocks.ReplayAll();

            _controllerContext = new ControllerContext(requestContext, controller);
            _controllerContext.RouteData.Values.Add("controller", viewPath);
        }
Ejemplo n.º 8
0
        public TemplateRenderer(
            IViewEngine viewEngine,
            ViewContext viewContext,
            ViewDataDictionary viewData,
            string templateName,
            bool readOnly)
        {
            if (viewEngine == null)
            {
                throw new ArgumentNullException(nameof(viewEngine));
            }

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

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

            _viewEngine = viewEngine;
            _viewContext = viewContext;
            _viewData = viewData;
            _templateName = templateName;
            _readOnly = readOnly;
        }
Ejemplo n.º 9
0
        void ConfigureRegistrar(IViewEngine engine, IViewProcessor processor)
        {
            var r = new ViewRegistrar(processor, engine);
            r.Add(new ReflectionViewRegistrar());

            _registrar = r;
        }
Ejemplo n.º 10
0
 static PagesHandler()
 {
     ViewEngine = new VelocityViewEngine();
     ViewEngine.Init();
     SchedulerProvider = Configuration.ConfigUtils.SchedulerProvider;
     SchedulerProvider.Init();
     SchedulerDataProvider = new DefaultSchedulerDataProvider(SchedulerProvider);
 }
		public void Before_each_test()
		{
			viewEngineManager = new DefaultViewEngineManager();
			firstEngine = new FirstEngine();
			viewEngineManager.RegisterEngineForExtesionLookup(firstEngine);
			secondEngine = new SecondEngine();
			viewEngineManager.RegisterEngineForExtesionLookup(secondEngine);
		}
Ejemplo n.º 12
0
        public DefaultMvcHandler(IControllerFactory controllerFactory, IViewEngine viewEngine)
        {
            Requires.NotNull(controllerFactory, "controllerFactory");
            Requires.NotNull(viewEngine, "viewEngine");

            _controllerFactory = controllerFactory;
            ViewEngineManager.Current.Add(viewEngine);
        }
Ejemplo n.º 13
0
        public ViewEngineResult(IView view, IViewEngine engine)
        {
            Precondition.Require(view, () => Error.ArgumentNull("view"));
            Precondition.Require(engine, () => Error.ArgumentNull("engine"));

            _view = view;
            _engine = engine;
        }
		public DefaultTerrificTemplateHandler(IViewEngine viewEngine, IModelProvider modelProvider,
			ITemplateRepository templateRepository, ILabelService labelService, IModuleRepository moduleRepository)
		{
			_viewEngine = viewEngine;
			_modelProvider = modelProvider;
			_templateRepository = templateRepository;
			_labelService = labelService;
			_moduleRepository = moduleRepository;
		}
Ejemplo n.º 15
0
        public void Setup(ViewEngineInspector sut, IInspectorContext context, IViewEngine viewEngine)
        {
            context.ProxyFactory.Setup(pf => pf.IsWrapInterfaceEligible<IViewEngine>(It.IsAny<Type>())).Returns(true);
            context.ProxyFactory.Setup(pf => pf.WrapInterface(It.IsAny<IViewEngine>(), It.IsAny<IEnumerable<IAlternateMethod>>(), Enumerable.Empty<object>())).Returns(viewEngine);

            sut.Setup(context);

            context.ProxyFactory.Verify(pf => pf.WrapInterface(It.IsAny<IViewEngine>(), It.IsAny<IEnumerable<IAlternateMethod>>(), Enumerable.Empty<object>()), Times.AtLeastOnce());
        }
 public void Setup()
 {
     _writer = new StringWriter();
     _context = new ViewContext();
     _viewEngine = MockRepository.GenerateMock<IViewEngine>();
     _engines = new ViewEngineCollection(new List<IViewEngine> { _viewEngine });
     _context.HttpContext = MvcMockHelpers.DynamicHttpContextBase();
     _renderContext = new RenderingContext(_writer, _context, _engines);
 }
Ejemplo n.º 17
0
        private DefaultViewFactory CreateFactory(params IViewEngine[] viewEngines)
        {
            if (viewEngines == null)
            {
                viewEngines = new IViewEngine[] { };
            }

            return new DefaultViewFactory(this.resolver, viewEngines, this.renderContextFactory, this.conventions, this.rootPathProvider);
        }
        public ViewEngineFormatter(IViewEngine viewEngine)
        {
            _viewEngine = viewEngine;

            foreach (var mediaTypeHeaderValue in _viewEngine.SupportedMediaTypes)
            {
                SupportedMediaTypes.Add(mediaTypeHeaderValue);
            }
        }
Ejemplo n.º 19
0
 protected HttpResponseMessage View(IViewEngine viewEngine, IPageViewDefinition siteDefinition)
 {
     var message = new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content =
             new PushStreamContent((o, c, t) => WriteToStream(o, viewEngine, siteDefinition),
                 new MediaTypeHeaderValue("text/html"))
     };
     return message;
 }
        // end-workaround
        public ThemedViewFactory()
        {
            var container = SparkEngineStarter.CreateContainer();
            _defaultViewFolder = container.GetService<IViewFolder>();
            _defaultEngine = container.GetService<IViewEngine>();

            // workaround
            _defaultViews = CompiledViewHolder.Current;
            // end-workaround
        }
Ejemplo n.º 21
0
 public void Init(IViewEngine viewEngine, IRequest httpReq, IResponse httpRes, IRazorView razorPage, 
     Dictionary<string, object> scopeArgs = null, ViewDataDictionary viewData = null)
 {
     ViewEngine = viewEngine;
     HttpRequest = httpReq as IHttpRequest;
     HttpResponse = httpRes as IHttpResponse;
     RazorPage = razorPage;
     //ScopeArgs = scopeArgs;
     this.viewData = viewData;
 }
		public void Setup()
		{
			_model = new GridModel<Person>();
			_people = new List<Person> {new Person {Id = 1, Name = "Jeremy", DateOfBirth = new DateTime(1987, 4, 19)}};
			_viewEngine = MockRepository.GenerateMock<IViewEngine>();
			_engines = new ViewEngineCollection(new List<IViewEngine> { _viewEngine });
			_writer = new StringWriter();
			_querystring= new NameValueCollection();
			RouteTable.Routes.MapRoute("default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
		}
Ejemplo n.º 23
0
        public ViewEngineResult(IView view, IViewEngine viewEngine) {
            if (view == null) {
                throw new ArgumentNullException("view");
            }
            if (viewEngine == null) {
                throw new ArgumentNullException("viewEngine");
            }

            View = view;
            ViewEngine = viewEngine;
        }
Ejemplo n.º 24
0
 private static Action<Stream> SafeInvokeViewEngine(IViewEngine viewEngine, ViewLocationResult locationResult, dynamic model)
 {
     try
     {
         return viewEngine.RenderView(locationResult, model);
     }
     catch (Exception)
     {
         return EmptyView;
     }
 }
Ejemplo n.º 25
0
        public void SetUp()
        {
            firstViewEngine = A.Fake<IViewEngine>();
            secondViewEngine = A.Fake<IViewEngine>();
            endpoint = A.Fake<IEndpoint>();
            firstTemplate = A.Fake<IViewTemplate>();
            secontTemplate = A.Fake<IViewTemplate>();

            A.CallTo(() => firstViewEngine.FindAllTemplates()).Returns(Enumerable.Repeat(firstTemplate, 1));
            A.CallTo(() => secondViewEngine.FindAllTemplates()).Returns(Enumerable.Repeat(secontTemplate, 1));

            viewEngineCollection = new ViewEngineCollection(new List<IViewEngine> { firstViewEngine, secondViewEngine });
        }
 public void Setup()
 {
     _model = new GridModel<Person>();
     _people = new ComparableSortList<Person>(new List<Person> { new Person { Id = 1, Name = "Jeremy", DateOfBirth = new DateTime(1987, 4, 19) } });
     _viewEngine = MockRepository.GenerateMock<IViewEngine>();
     _engines = new ViewEngineCollection(new List<IViewEngine> { _viewEngine });
     _writer = new StringWriter();
     _context = new ViewContext();
     _context.HttpContext = MvcMockHelpers.DynamicHttpContextBase();
     var response = MockRepository.GenerateStub<HttpResponseBase>();
     _context.HttpContext.Stub(p => p.Response).Return(response);
     response.Stub(p => p.Output).Return(_writer);
 }
Ejemplo n.º 27
0
 public TemplateRenderer(
     [NotNull] IViewEngine viewEngine,
     [NotNull] ViewContext viewContext,
     [NotNull] ViewDataDictionary viewData,
     string templateName,
     bool readOnly)
 {
     _viewEngine = viewEngine;
     _viewContext = viewContext;
     _viewData = viewData;
     _templateName = templateName;
     _readOnly = readOnly;
 }
Ejemplo n.º 28
0
        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;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of <see cref="ViewContext"/>.
 /// </summary>
 /// <param name="actionContext">The <see cref="ActionContext"/>.</param>
 /// <param name="view">The <see cref="IView"/> being rendered.</param>
 /// <param name="viewData">The <see cref="ViewDataDictionary"/>.</param>
 /// <param name="tempData">The <see cref="ITempDataDictionary"/>.</param>
 /// <param name="writer">The <see cref="TextWriter"/> to render output to.</param>
 public ViewContext(
     [NotNull] IView view,
     [NotNull] ViewDataDictionary viewData,
     [NotNull] TextWriter writer,
     IMetadata metadata,
     IExecutionContext executionContext,
     IViewEngine viewEngine)
 {
     View = view;
     ViewData = viewData;
     Writer = writer;
     Metadata = metadata;
     ExecutionContext = executionContext;
     ViewEngine = viewEngine;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of <see cref="ViewContext"/>.
 /// </summary>
 /// <param name="actionContext">The <see cref="ActionContext"/>.</param>
 /// <param name="view">The <see cref="IView"/> being rendered.</param>
 /// <param name="viewData">The <see cref="ViewDataDictionary"/>.</param>
 /// <param name="tempData">The <see cref="ITempDataDictionary"/>.</param>
 /// <param name="writer">The <see cref="TextWriter"/> to render output to.</param>
 public ViewContext(
     [NotNull] IView view,
     [NotNull] ViewDataDictionary viewData,
     [NotNull] TextWriter writer,
     IDocument document,
     IExecutionContext executionContext,
     IViewEngine viewEngine)
 {
     View = view;
     ViewData = viewData;
     Writer = writer;
     Document = document;
     ExecutionContext = executionContext;
     ViewEngine = viewEngine;
 }
Ejemplo n.º 31
0
 public void Init(IViewEngine viewEngine, ViewDataDictionary viewData, IHttpResponse httpRes)
 {
     this.Response = httpRes;
     Html.Init(viewEngine, viewData);
 }
 protected ViewEngineResponseFiller(IViewEngine viewEngine)
 {
     _viewEngine = viewEngine;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// IViewEngine wrapper that records view usages
 /// </summary>
 /// <param name="engine">View Engine to be wrapped</param>
 /// <param name="hound">Parent hound to keep track of usage</param>
 public ViewTrackerRazorEngine(IViewEngine engine, IHound hound)
 {
     _engine = engine;
     _hound  = hound;
 }
Ejemplo n.º 34
0
        public static void Init()
        {
            lock (_initLock)
            {
                if (_initialized)
                {
                    return;
                }

                _initialized = true;

                Regex.CacheSize = 100;

                _version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

                string applicationClassName = null;

                foreach (string configKey in ConfigurationManager.AppSettings.Keys)
                {
                    string configValue = ConfigurationManager.AppSettings[configKey];

                    switch (configKey.ToLower())
                    {
                    case "promesh.defaultlayout":
                    case "mvc.defaultlayout":
                        DefaultLayout = configValue;
                        break;

                    case "promesh.templatepath":
                    case "mvc.templatepath":
                        TemplatePath = configValue;
                        break;

                    case "promesh.uselanguagepath":
                    case "mvc.uselanguagepath":
                        UseLanguagePath = (configValue.ToLower() == "true");
                        break;

                    case "promesh.defaultlanguage":
                    case "mvc.defaultlanguage":
                        DefaultLanguage = configValue;
                        break;

                    case "promesh.applicationclass":
                    case "mvc.applicationclass":
                        applicationClassName = configValue;
                        break;
                    }

                    if (configKey.ToLower().StartsWith("mvc.viewengine"))
                    {
                        IViewEngine viewEngine = (IViewEngine)Activator.CreateInstance(Type.GetType(configValue));

                        string ext = configKey.Length > 15 ? configKey.Substring(14) : null;

                        ViewEngines.Add(viewEngine, ext);
                    }
                }

                if (applicationClassName == null)
                {
                    throw new Exception("No Mvc.ApplicationClass defined in web.config");
                }

                Type appType = Type.GetType(applicationClassName, false);

                if (appType == null)
                {
                    throw new Exception("Application class {" + applicationClassName + "} could not be loaded");
                }

                MethodInfo initMethod = appType.GetMethod("Init", new Type[0]);

                if (initMethod == null || !initMethod.IsStatic)
                {
                    throw new Exception("No \"public static void Init()\" method defined for class " + appType.Name);
                }

                RegisterAssembly(appType.Assembly);
                RegisterAssembly(Assembly.GetExecutingAssembly());

                initMethod.Invoke(null, null);

                ViewEngines.Add(new ViciViewEngine(), "htm");

                LoadControllerClasses();

                StringConverter.RegisterStringConverter(_objectBinder);
            }
        }
Ejemplo n.º 35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProfilingViewEngine"/> class.
 /// </summary>
 /// <param name="wrapped">Original view engine to profile</param>
 public ProfilingViewEngine(IViewEngine wrapped) => _wrapped = wrapped;
Ejemplo n.º 36
0
 public ProfilingViewEngine(IViewEngine inner, IProfiler profiler)
 {
     Inner     = inner;
     _profiler = profiler;
     _name     = inner.GetType().Name;
 }
Ejemplo n.º 37
0
 public ProfilingViewEngine(IViewEngine wrapped)
 {
     this.wrapped = wrapped;
 }
Ejemplo n.º 38
0
 public MockMobileCapableWebFormViewEngine(IView view, IViewEngine viewEngine, string viewPathExpected)
 {
     this.view             = view;
     this.viewEngine       = viewEngine;
     this.viewPathExpected = viewPathExpected;
 }
Ejemplo n.º 39
0
 public ECommPingController(IResponseBuilder responseBuilder, IViewEngine viewEngine)
 {
     _responseBuilder = responseBuilder;
     _viewEngine      = viewEngine;
 }
Ejemplo n.º 40
0
 public HtmlFileGenerator(IDataDockUriService uriService, IResourceFileMapper resourceMap, IViewEngine viewEngine, IProgressLog progressLog, int reportInterval, Dictionary <string, object> addVariables)
 {
     _resourceMap       = resourceMap;
     _viewEngine        = viewEngine;
     _progressLog       = progressLog;
     _numFilesGenerated = 0;
     _uriService        = uriService;
     _reportInterval    = reportInterval;
     _addVariables      = addVariables ?? new Dictionary <string, object>();
 }
Ejemplo n.º 41
0
 protected MasterFiller(IViewEngine viewEngine, ISchedulerDataProvider schedulerDataProvider) : base(viewEngine)
 {
     _schedulerDataProvider = schedulerDataProvider;
 }
 private static ViewEngineResult GetViewEngineResult(Controller controller, string viewName, bool isPartial, IViewEngine viewEngine)
 {
     if (viewName.StartsWith("~/"))
     {
         var hostingEnv = controller.HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;
         return(viewEngine.GetView(hostingEnv.WebRootPath, viewName, !isPartial));
     }
     else
     {
         return(viewEngine.FindView(controller.ControllerContext, viewName, !isPartial));
     }
 }
Ejemplo n.º 43
0
 private ViewEngineStartupContext CreateViewEngineStartupContext(IViewEngine viewEngine)
 {
     return(new ViewEngineStartupContext(
                this.viewCache,
                GetViewsThatEngineCanRender(viewEngine)));
 }
Ejemplo n.º 44
0
 public TracingViewEngine(IViewEngine innerViewEngine)
 {
     _innerViewEngine = innerViewEngine;
 }
Ejemplo n.º 45
0
 private IEnumerable <ViewLocationResult> GetViewsThatEngineCanRender(IViewEngine viewEngine)
 {
     return(viewEngine.Extensions.SelectMany(extension => this.viewLocationCache.Where(x => x.Extension.Equals(extension))).ToList());
 }
Ejemplo n.º 46
0
 public ViewEngineAgent()
 {
     _razorViewEngine = new RazorViewEngine();
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Attempts to locate the view named <paramref name="viewName"/> using the specified
 /// <paramref name="viewEngine"/>.
 /// </summary>
 /// <param name="viewEngine">The <see cref="IViewEngine"/> used to locate the view.</param>
 /// <param name="context">The <see cref="ActionContext"/> for the executing action.</param>
 /// <param name="viewName">The view to find.</param>
 /// <returns></returns>
 protected abstract ViewEngineResult FindView(IViewEngine viewEngine,
                                              ActionContext context,
                                              string viewName);
Ejemplo n.º 48
0
 public ResourceProvider(IViewEngine previousViewEngine)
 {
     _previousViewEngine = previousViewEngine;
 }
Ejemplo n.º 49
0
 /// <summary>
 /// Configures the bootstrapper to use the provided instance of <see cref="IViewEngine"/>.
 /// </summary>
 /// <param name="viewEngine">The <see cref="IViewEngine"/> instance that should be used by the bootstrapper.</param>
 /// <returns>An instance to the current <see cref="FakeNancyBootstrapperConfigurator"/>.</returns>
 public FakeNancyBootstrapperConfigurator ViewEngine(IViewEngine viewEngine)
 {
     this.bootstrapper.configuredInstances[typeof(IViewEngine)] = viewEngine;
     return(this);
 }
 /// <inheritdoc />
 public new IAndViewComponentTestBuilder WithViewEngine(IViewEngine viewEngine)
 {
     base.WithViewEngine(viewEngine);
     return(this);
 }
Ejemplo n.º 51
0
 public ViewResult(IServiceProvider serviceProvider, IViewEngine viewEngine)
 {
     _serviceProvider = serviceProvider;
     _viewEngine      = viewEngine;
 }
 protected Controller()
 {
     this.viewEngine = new SisViewEngine();
     this.ModelState = new ModelStateDictionary();
 }
Ejemplo n.º 53
0
 public RequestHandlerBase()
 {
     _viewEngine    = RazorTemplateEngine.GetEngine();
     _routeExecuter = new RouteExecuter();
 }
Ejemplo n.º 54
0
 public IViewEngine BindBareEngines(Func <IViewEngine> factory)
 {
     return(bare ?? (bare = factory()));
 }
Ejemplo n.º 55
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HtmlHelpers"/> class.
 /// </summary>
 /// <param name="engine"></param>
 /// <param name="renderContext"></param>
 public HtmlHelpers(IViewEngine engine, IRenderContext renderContext)
 {
     this.engine        = engine;
     this.renderContext = renderContext;
 }
 private ViewEngineStartupContext CreateViewEngineStartupContext(IViewEngine viewEngine)
 {
     return(new ViewEngineStartupContext(
                this.viewCache,
                this.viewLocator));
 }
 public BlockComponentDirective(IViewComponentFactory viewComponentFactory, IViewEngine viewEngine) : base(viewComponentFactory, viewEngine)
 {
 }
        public async Task <string> RenderViewToStringAsync(string viewName, object model, IViewEngine viewEngine)
        {
            var actionContext = await GetActionContextAsync();

            var view = FindView(actionContext, viewName, viewEngine);

            using var output = new ZStringWriter();
            var viewContext = new ViewContext(
                actionContext,
                view,
                new ViewDataDictionary(
                    metadataProvider: new EmptyModelMetadataProvider(),
                    modelState: new ModelStateDictionary())
            {
                Model = model
            },
                new TempDataDictionary(
                    actionContext.HttpContext,
                    _tempDataProvider),
                output,
                new HtmlHelperOptions());

            await view.RenderAsync(viewContext);

            return(output.ToString());
        }
Ejemplo n.º 59
0
 protected Controller()
 {
     this.viewEngine = new SisViewEngine();
 }
Ejemplo n.º 60
0
 public static void RegisterViewEngine(IViewEngine item)
 {
     ViewEngines.Engines.Clear();
     ViewEngines.Engines.Add(item);
 }