public void Register(IAppHost appHost) { this.ScanRootPath = this.ScanRootPath ?? appHost.Config.WebHostPhysicalPath; this.VirtualFileSources = VirtualFileSources ?? appHost.VirtualFileSources; this.WebHostUrl = WebHostUrl ?? appHost.Config.WebHostUrl; this.EnableLiveReload = this.EnableLiveReload ?? appHost.Config.DebugMode; if (CheckLastModifiedForChanges == true) { EnableLiveReload = false; //Don't enable both File Watcher + LastModified checks } this.PrecompilePages = this.PrecompilePages ?? !this.EnableLiveReload; this.WaitForPrecompilationOnStartup = this.WaitForPrecompilationOnStartup ?? !this.EnableLiveReload; if (LoadUnloadedAssemblies) { var loadedAssemblyNames = CompilerServices .GetLoadedAssemblies() .Where(x => !x.IsDynamic) .Map(x => x.FullName.SplitOnFirst(',')[0]); foreach (var razorNamespace in appHost.Config.RazorNamespaces) { try { if (razorNamespace.StartsWith("System") || razorNamespace.StartsWith("ServiceStack")) { continue; } if (!loadedAssemblyNames.Contains(razorNamespace)) { Assembly.Load(razorNamespace); } } catch { /*Ignore namespaces that don't map to assemblies*/ } } } try { Init(); BindToAppHost(appHost); } catch (Exception ex) { appHost.NotifyStartupException(ex); throw; } }
public void Register(IAppHost appHost) { this.ScanRootPath = this.ScanRootPath ?? appHost.WebHostPhysicalPath; this.VirtualFileSources = VirtualFileSources ?? appHost.VirtualFileSources; this.WebHostUrl = WebHostUrl ?? appHost.Config.WebHostUrl; this.EnableLiveReload = this.EnableLiveReload ?? appHost.Config.DebugMode; if (CheckLastModifiedForChanges == true) { EnableLiveReload = false; //Don't enable both File Watcher + LastModified checks } this.PrecompilePages = this.PrecompilePages ?? !this.EnableLiveReload; this.WaitForPrecompilationOnStartup = this.WaitForPrecompilationOnStartup ?? !this.EnableLiveReload; if (LoadUnloadedAssemblies) { var loadedAssemblyNames = CompilerServices .GetLoadedAssemblies() .Where(x => !x.IsDynamic) .Map(x => x.FullName.LeftPart(',')); foreach (var razorNamespace in appHost.Config.RazorNamespaces) { try { if (razorNamespace.StartsWith("System") || razorNamespace.StartsWith("ServiceStack")) { continue; } if (!loadedAssemblyNames.Contains(razorNamespace)) { Assembly.Load(razorNamespace); } } catch { /*Ignore namespaces that don't map to assemblies*/ } } } Init(); BindToAppHost(appHost); appHost.GetPlugin <MetadataFeature>() ?.AddLink(MetadataFeature.AvailableFeatures, "http://docs.servicestack.net/razor-notes", nameof(RazorFormat)); }