public RazorViewEngineFixture() { StaticConfiguration.DisableErrorTraces = false; this.configuration = A.Fake <IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration); var cache = A.Fake <IViewCache>(); A.CallTo(() => cache.GetOrAdd(A <ViewLocationResult> .Ignored, A <Func <ViewLocationResult, Func <INancyRazorView> > > .Ignored)) .ReturnsLazily(x => { var result = x.GetArgument <ViewLocationResult>(0); return(x.GetArgument <Func <ViewLocationResult, Func <INancyRazorView> > >(1).Invoke(result)); }); this.renderContext = A.Fake <IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A <string> .Ignored, A <object> .Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument <string>(0); return(FindView(viewName)); }); this.rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); AppDomainAssemblyTypeScanner.AddAssembliesToScan("Nancy.ViewEngines.Razor.Tests.Models.dll"); }
public RazorViewEngineFixture() { var environment = new DefaultNancyEnvironment(); environment.Tracing( enabled: true, displayErrorTraces: true); this.configuration = A.Fake<IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration, environment); var cache = A.Fake<IViewCache>(); A.CallTo(() => cache.GetOrAdd(A<ViewLocationResult>.Ignored, A<Func<ViewLocationResult, Func<INancyRazorView>>>.Ignored)) .ReturnsLazily(x => { var result = x.GetArgument<ViewLocationResult>(0); return x.GetArgument<Func<ViewLocationResult, Func<INancyRazorView>>>(1).Invoke(result); }); this.renderContext = A.Fake<IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A<string>.Ignored, A<object>.Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument<string>(0); return FindView(viewName); }); this.rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); AppDomainAssemblyTypeScanner.AddAssembliesToScan("Nancy.ViewEngines.Razor.Tests.Models.dll"); }
public RazorViewEngineFixture() { var environment = new DefaultNancyEnvironment(); environment.Tracing( enabled: true, displayErrorTraces: true); this.configuration = A.Fake <IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration, environment, new AppDomainAssemblyCatalog()); var cache = A.Fake <IViewCache>(); A.CallTo(() => cache.GetOrAdd(A <ViewLocationResult> .Ignored, A <Func <ViewLocationResult, Func <INancyRazorView> > > .Ignored)) .ReturnsLazily(x => { var result = x.GetArgument <ViewLocationResult>(0); return(x.GetArgument <Func <ViewLocationResult, Func <INancyRazorView> > >(1).Invoke(result)); }); this.renderContext = A.Fake <IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A <string> .Ignored, A <object> .Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument <string>(0); return(FindView(viewName)); }); this.rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); }
public RazorViewEngineFixture() { this.configuration = A.Fake<IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration); var cache = A.Fake<IViewCache>(); A.CallTo(() => cache.GetOrAdd(A<ViewLocationResult>.Ignored, A<Func<ViewLocationResult, Func<NancyRazorViewBase>>>.Ignored)) .ReturnsLazily(x => { var result = x.GetArgument<ViewLocationResult>(0); return x.GetArgument<Func<ViewLocationResult, Func<NancyRazorViewBase>>>(1).Invoke(result); }); this.renderContext = A.Fake<IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A<string>.Ignored, A<object>.Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument<string>(0); return FindView(viewName); ; }); this.rootPathProvider = A.Fake<IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); }
public RazorViewEngineFixture() { this.configuration = A.Fake <IRazorConfiguration>(); this.textResource = A.Fake <ITextResource>(); this.engine = new RazorViewEngine(this.configuration, this.textResource); var cache = A.Fake <IViewCache>(); A.CallTo(() => cache.GetOrAdd(A <ViewLocationResult> .Ignored, A <Func <ViewLocationResult, Func <NancyRazorViewBase> > > .Ignored)) .ReturnsLazily(x => { var result = x.GetArgument <ViewLocationResult>(0); return(x.GetArgument <Func <ViewLocationResult, Func <NancyRazorViewBase> > >(1).Invoke(result)); }); this.renderContext = A.Fake <IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); A.CallTo(() => this.renderContext.LocateView(A <string> .Ignored, A <object> .Ignored)) .ReturnsLazily(x => { var viewName = x.GetArgument <string>(0); return(FindView(viewName));; }); this.rootPathProvider = A.Fake <IRootPathProvider>(); A.CallTo(() => this.rootPathProvider.GetRootPath()).Returns(Path.Combine(Environment.CurrentDirectory, "TestViews")); this.fileSystemViewLocationProvider = new FileSystemViewLocationProvider(this.rootPathProvider, new DefaultFileSystemReader()); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> /// <param name="assemblyCatalog">An <see cref="IAssemblyCatalog"/> instance.</param> public RazorViewEngine(IRazorConfiguration configuration, INancyEnvironment environment, IAssemblyCatalog assemblyCatalog) { this.razorAssemblyProvider = new RazorAssemblyProvider(configuration, assemblyCatalog); this.viewRenderer = new CSharpRazorViewRenderer(this.razorAssemblyProvider); this.razorConfiguration = configuration; this.traceConfiguration = environment.GetValue<TraceConfiguration>(); this.AddDefaultNameSpaces(this.viewRenderer.Host); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> /// <param name="assemblyCatalog">An <see cref="IAssemblyCatalog"/> instance.</param> public RazorViewEngine(IRazorConfiguration configuration, INancyEnvironment environment, IAssemblyCatalog assemblyCatalog) { this.razorAssemblyProvider = new RazorAssemblyProvider(configuration, assemblyCatalog); this.viewRenderer = new CSharpRazorViewRenderer(this.razorAssemblyProvider); this.razorConfiguration = configuration; this.traceConfiguration = environment.GetValue <TraceConfiguration>(); this.AddDefaultNameSpaces(this.viewRenderer.Host); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration) { this.viewRenderers = new List<IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration) { this.viewRenderers = new List <IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="textResource">The <see cref="ITextResource"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration, ITextResource textResource) { this.viewRenderers = new List<IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; this.textResource = textResource; }
public RazorViewCompiler(IFileSystem fileSystem, IRazorConfiguration razorConfiguration) { this.fileSystem = fileSystem; this.razorConfiguration = razorConfiguration; this.razorTemplateEngine = BuildRazorTemplateEngine(RazorProjectFileSystem.Create(this.fileSystem.GetFullPath("~/"))); var defaultTagHelpers = razorConfiguration.GetDefaultTagHelpers(); var defaultDirectivesProjectItem = new DefaultDirectivesProjectItem(this.razorConfiguration.GetDefaultNamespaces(), defaultTagHelpers); this.defaultImports = new[] { RazorSourceDocument.ReadFrom(defaultDirectivesProjectItem) }; this.GetReferenceAssemblies(); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="textResource">The <see cref="ITextResource"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration, ITextResource textResource) { this.viewRenderers = new List <IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; this.textResource = textResource; }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration) { this.viewRenderers = new List<IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; foreach (var renderer in this.viewRenderers) { this.AddDefaultNameSpaces(renderer.Host); } }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> public RazorViewEngine(IRazorConfiguration configuration) { this.viewRenderers = new List <IRazorViewRenderer> { new CSharp.CSharpRazorViewRenderer(), new VisualBasic.VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; foreach (var renderer in this.viewRenderers) { this.AddDefaultNameSpaces(renderer.Host); } }
public RazorViewCompilerFixture() { this.configuration = A.Fake<IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration); var cache = A.Fake<IViewCache>(); A.CallTo(() => cache.GetOrAdd(A<ViewLocationResult>.Ignored, A<Func<ViewLocationResult, Func<NancyRazorViewBase>>>.Ignored)) .ReturnsLazily(x => { var result = x.GetArgument<ViewLocationResult>(0); return x.GetArgument<Func<ViewLocationResult, Func<NancyRazorViewBase>>>(1).Invoke(result); }); this.renderContext = A.Fake<IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> public RazorViewEngine(IRazorConfiguration configuration, INancyEnvironment environment) { this.viewRenderers = new List<IRazorViewRenderer> { new CSharpRazorViewRenderer(), new VisualBasicRazorViewRenderer() }; this.razorConfiguration = configuration; this.traceConfiguration = environment.GetValue<TraceConfiguration>(); foreach (var renderer in this.viewRenderers) { this.AddDefaultNameSpaces(renderer.Host); } }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration">The <see cref="IRazorConfiguration"/> that should be used by the engine.</param> /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param> /// <param name="assemblyCatalog">An <see cref="IAssemblyCatalog"/> instance.</param> public RazorViewEngine(IRazorConfiguration configuration, INancyEnvironment environment, IAssemblyCatalog assemblyCatalog) { this.viewRenderers = new List <IRazorViewRenderer> { new CSharpRazorViewRenderer(assemblyCatalog), new VisualBasicRazorViewRenderer(assemblyCatalog) }; this.razorConfiguration = configuration; this.assemblyCatalog = assemblyCatalog; this.traceConfiguration = environment.GetValue <TraceConfiguration>(); foreach (var renderer in this.viewRenderers) { this.AddDefaultNameSpaces(renderer.Host); } }
public RazorViewCompilerFixture() { this.configuration = A.Fake <IRazorConfiguration>(); this.engine = new RazorViewEngine(this.configuration); var cache = A.Fake <IViewCache>(); A.CallTo(() => cache.GetOrAdd(A <ViewLocationResult> .Ignored, A <Func <ViewLocationResult, Func <NancyRazorViewBase> > > .Ignored)) .ReturnsLazily(x => { var result = x.GetArgument <ViewLocationResult>(0); return(x.GetArgument <Func <ViewLocationResult, Func <NancyRazorViewBase> > >(1).Invoke(result)); }); this.renderContext = A.Fake <IRenderContext>(); A.CallTo(() => this.renderContext.ViewCache).Returns(cache); }
/// <summary> /// Initializes a new instance of the <see cref="RazorAssemblyProvider"/> class. /// </summary> /// <param name="configuration">An <see cref="IRazorConfiguration"/> instance.</param> /// <param name="assemblyCatalog">An <see cref="IAssemblyCatalog"/> instance.</param> public RazorAssemblyProvider(IRazorConfiguration configuration, IAssemblyCatalog assemblyCatalog) { this.configuration = configuration; this.assemblyCatalog = assemblyCatalog; this.assemblies = new Lazy<IReadOnlyCollection<Assembly>>(this.GetAllAssemblies); }
public AssetEnrichedRazorViewCompiler(IJavascriptPreprocessor jsPreprocessor, IEnumerable <ICssPreprocessor> cssPreprocessors, IFileSystem fileSystem, IAssetLoader assetLoader, IRazorConfiguration razorConfiguration) : base(fileSystem, razorConfiguration) { this.jsPreprocessor = jsPreprocessor; this.cssPreprocessors = cssPreprocessors; this.assetLoader = assetLoader; }
/// <summary> /// Initializes a new instance of the <see cref="RazorAssemblyProvider"/> class. /// </summary> /// <param name="configuration">An <see cref="IRazorConfiguration"/> instance.</param> /// <param name="assemblyCatalog">An <see cref="IAssemblyCatalog"/> instance.</param> public RazorAssemblyProvider(IRazorConfiguration configuration, IAssemblyCatalog assemblyCatalog) { this.configuration = configuration; this.assemblyCatalog = assemblyCatalog; this.assemblies = new Lazy <IReadOnlyCollection <Assembly> >(this.GetAllAssemblies); }
public AssetEnrichedRazorViewCompiler(IRazorConfiguration razorConfiguration, IJavascriptCompressor jsCompressor, ICssPreprocessor cssPreprocessor, IFileSystem fileSystem, IAssetLoader assetLoader) : base(razorConfiguration, fileSystem) { this.jsCompressor = jsCompressor; this.cssPreprocessor = cssPreprocessor; this.assetLoader = assetLoader; }
/// <summary> /// Initializes a new instance of the <see cref="RazorViewEngine"/> class. /// </summary> /// <param name="configuration"></param> public RazorViewEngine(IRazorConfiguration configuration) { this.razorConfiguration = configuration; this.engine = this.GetRazorTemplateEngine(); this.codeDomProvider = new CSharpCodeProvider(); }
public RazorViewCompiler(IRazorConfiguration razorConfiguration, IFileSystem fileSystem) { this.razorConfiguration = razorConfiguration; this.fileSystem = fileSystem; }