Exemple #1
0
        protected override void OnBeforeCompilePath(CompilingPathEventArgs args)
        {
            base.OnBeforeCompilePath(args);

            if (!(args.Host is RazorHost))
            {
                args.Host = RazorHost.CreateFromAnother(args.Host);
            }
        }
 static void RazorBuildProvider_CompilingPath(object sender, CompilingPathEventArgs e)
 {
     // If MVC-Razor was already going to handle this
     //if (e.Host is MvcWebPageRazorHost)
     //{
     //    // Switch it out for our custom host.
     //    e.Host = new MyRazorHost(e.Host.VirtualPath, e.Host.PhysicalPath);
     //}
 }
Exemple #3
0
 private Type GetTypeFromVirtualPathNoCache(string virtualPath)
 {
     using (DoProfileStep($"{nameof(RoslynRazorViewEngine)}: Compiling {virtualPath}"))
     {
         OnCodeGenerationStarted();
         var args = new CompilingPathEventArgs(virtualPath, WebRazorHostFactory.CreateHostFromConfig(virtualPath));
         OnBeforeCompilePath(args);
         var host        = args.Host;
         var razorResult = RunRazorGenerator(virtualPath, host);
         var syntaxTree  = GetSyntaxTree(host, razorResult);
         var assembly    = CompileToAssembly(host, syntaxTree);
         return(assembly.GetType($"{host.DefaultNamespace}.{host.DefaultClassName}"));
     }
 }
Exemple #4
0
 /// <summary>
 /// Raises the <see cref="CompilingPath"/> event.
 /// </summary>
 /// <param name="args"></param>
 protected virtual void OnBeforeCompilePath(CompilingPathEventArgs args) =>
 CompilingPath?.Invoke(this, args);