protected virtual void OnBeforeCompilePath(CompilingPathEventArgs args) { EventHandler <CompilingPathEventArgs> handler = CompilingPath; if (handler != null) { handler(this, args); } }
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); //} }
protected internal virtual WebPageRazorHost CreateHost() { // Get the host from config WebPageRazorHost configuredHost = GetHostFromConfig(); // Fire the event CompilingPathEventArgs args = new CompilingPathEventArgs(VirtualPath, configuredHost); OnBeforeCompilePath(args); // Return the host provided in the args, which may have been changed by the handler return(args.Host); }
protected virtual void OnBeforeCompilePath(CompilingPathEventArgs args) { EventHandler<CompilingPathEventArgs> handler = CompilingPath; if (handler != null) { handler(this, args); } }
protected internal virtual WebPageRazorHost CreateHost() { // Get the host from config WebPageRazorHost configuredHost = GetHostFromConfig(); // Fire the event CompilingPathEventArgs args = new CompilingPathEventArgs(VirtualPath, configuredHost); OnBeforeCompilePath(args); // Return the host provided in the args, which may have been changed by the handler return args.Host; }
/// <summary> /// Raises the <see cref="CompilingPath"/> event. /// </summary> /// <param name="args"></param> protected virtual void OnBeforeCompilePath(CompilingPathEventArgs args) => CompilingPath?.Invoke(this, args);
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}"); } }