コード例 #1
0
        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");
        }
コード例 #2
0
ファイル: RazorViewEngineFixture.cs プロジェクト: l3m/Nancy
        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");
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
ファイル: RazorViewEngine.cs プロジェクト: VPashkov/Nancy
 /// <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);
 }
コード例 #7
0
ファイル: RazorViewEngine.cs プロジェクト: zhuozhuowang/Nancy
 /// <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);
 }
コード例 #8
0
ファイル: RazorViewEngine.cs プロジェクト: half-ogre/Nancy
        /// <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;
        }
コード例 #9
0
ファイル: RazorViewEngine.cs プロジェクト: couellet/Nancy
        /// <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;
        }
コード例 #10
0
ファイル: RazorViewEngine.cs プロジェクト: synhershko/Nancy
        /// <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;
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        /// <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;
        }
コード例 #13
0
ファイル: RazorViewEngine.cs プロジェクト: JulianRooze/Nancy
        /// <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);
            }
        }
コード例 #14
0
        /// <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);
            }
        }
コード例 #15
0
        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);
        }
コード例 #16
0
ファイル: RazorViewEngine.cs プロジェクト: l3m/Nancy
        /// <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);
            }
        }
コード例 #17
0
        /// <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);
            }
        }
コード例 #18
0
        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);
        }
コード例 #19
0
 /// <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);
 }
コード例 #20
0
 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;
 }
コード例 #21
0
 /// <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);
 }
コード例 #22
0
 public AssetEnrichedRazorViewCompiler(IRazorConfiguration razorConfiguration, IJavascriptCompressor jsCompressor, ICssPreprocessor cssPreprocessor, IFileSystem fileSystem, IAssetLoader assetLoader) : base(razorConfiguration, fileSystem)
 {
     this.jsCompressor    = jsCompressor;
     this.cssPreprocessor = cssPreprocessor;
     this.assetLoader     = assetLoader;
 }
コード例 #23
0
 /// <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();
 }
コード例 #24
0
 public RazorViewCompiler(IRazorConfiguration razorConfiguration, IFileSystem fileSystem)
 {
     this.razorConfiguration = razorConfiguration;
     this.fileSystem         = fileSystem;
 }