/// <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); }
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; }
public StreamContent CreateContent(IViewEngine viewEngine) { var memoryStream = new MemoryStream(); WriteToStream(memoryStream, viewEngine); memoryStream.Position = 0; return new StreamContent(memoryStream); }
public ViewViewComponentResult([NotNull] IViewEngine viewEngine, string viewName, ViewDataDictionary viewData) { _viewEngine = viewEngine; ViewName = viewName; ViewData = viewData; }
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); }
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; }
void ConfigureRegistrar(IViewEngine engine, IViewProcessor processor) { var r = new ViewRegistrar(processor, engine); r.Add(new ReflectionViewRegistrar()); _registrar = r; }
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); }
public DefaultMvcHandler(IControllerFactory controllerFactory, IViewEngine viewEngine) { Requires.NotNull(controllerFactory, "controllerFactory"); Requires.NotNull(viewEngine, "viewEngine"); _controllerFactory = controllerFactory; ViewEngineManager.Current.Add(viewEngine); }
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; }
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); }
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); } }
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 }
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 }); }
public ViewEngineResult(IView view, IViewEngine viewEngine) { if (view == null) { throw new ArgumentNullException("view"); } if (viewEngine == null) { throw new ArgumentNullException("viewEngine"); } View = view; ViewEngine = viewEngine; }
private static Action<Stream> SafeInvokeViewEngine(IViewEngine viewEngine, ViewLocationResult locationResult, dynamic model) { try { return viewEngine.RenderView(locationResult, model); } catch (Exception) { return EmptyView; } }
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); }
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; }
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="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; }
/// <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; }
public void Init(IViewEngine viewEngine, ViewDataDictionary viewData, IHttpResponse httpRes) { this.Response = httpRes; Html.Init(viewEngine, viewData); }
protected ViewEngineResponseFiller(IViewEngine viewEngine) { _viewEngine = viewEngine; }
/// <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; }
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); } }
/// <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;
public ProfilingViewEngine(IViewEngine inner, IProfiler profiler) { Inner = inner; _profiler = profiler; _name = inner.GetType().Name; }
public ProfilingViewEngine(IViewEngine wrapped) { this.wrapped = wrapped; }
public MockMobileCapableWebFormViewEngine(IView view, IViewEngine viewEngine, string viewPathExpected) { this.view = view; this.viewEngine = viewEngine; this.viewPathExpected = viewPathExpected; }
public ECommPingController(IResponseBuilder responseBuilder, IViewEngine viewEngine) { _responseBuilder = responseBuilder; _viewEngine = viewEngine; }
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>(); }
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)); } }
private ViewEngineStartupContext CreateViewEngineStartupContext(IViewEngine viewEngine) { return(new ViewEngineStartupContext( this.viewCache, GetViewsThatEngineCanRender(viewEngine))); }
public TracingViewEngine(IViewEngine innerViewEngine) { _innerViewEngine = innerViewEngine; }
private IEnumerable <ViewLocationResult> GetViewsThatEngineCanRender(IViewEngine viewEngine) { return(viewEngine.Extensions.SelectMany(extension => this.viewLocationCache.Where(x => x.Extension.Equals(extension))).ToList()); }
public ViewEngineAgent() { _razorViewEngine = new RazorViewEngine(); }
/// <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);
public ResourceProvider(IViewEngine previousViewEngine) { _previousViewEngine = previousViewEngine; }
/// <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); }
public ViewResult(IServiceProvider serviceProvider, IViewEngine viewEngine) { _serviceProvider = serviceProvider; _viewEngine = viewEngine; }
protected Controller() { this.viewEngine = new SisViewEngine(); this.ModelState = new ModelStateDictionary(); }
public RequestHandlerBase() { _viewEngine = RazorTemplateEngine.GetEngine(); _routeExecuter = new RouteExecuter(); }
public IViewEngine BindBareEngines(Func <IViewEngine> factory) { return(bare ?? (bare = factory())); }
/// <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()); }
protected Controller() { this.viewEngine = new SisViewEngine(); }
public static void RegisterViewEngine(IViewEngine item) { ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(item); }