Permalink
Browse files

Add PreApplicationStartCode in which BuildProvider.RegisterBuildProvi…

…der() can be called
  • Loading branch information...
1 parent 35e09a8 commit e5e612929d6475308ade427275cabfd92277a2e4 @dahlbyk committed Jan 7, 2011
@@ -11,4 +11,5 @@ open System.Reflection
[<assembly: AssemblyVersion("1.0.0.0")>]
[<assembly: AssemblyFileVersion("1.0.0.0")>]
+[<assembly: System.Web.PreApplicationStartMethod(typeof<FSRazor.Mvc.PreApplicationStartCode>, "Start")>]
()
@@ -38,6 +38,7 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
+ <Reference Include="System.Web" />
<Reference Include="System.Web.Mvc">
<HintPath>..\..\lib\ASP.NET MVC\v3\System.Web.Mvc.dll</HintPath>
</Reference>
@@ -53,6 +54,7 @@
<Compile Include="MvcFSharpRazorCodeGenerator.fs" />
<Compile Include="MvcWebPageRazorHost.fs" />
<Compile Include="FSRazorViewEngine.fs" />
+ <Compile Include="PreApplicationStartCode.fs" />
<Compile Include="AssemblyInfo.fs" />
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,18 @@
+namespace FSRazor.Mvc
+
+open FSRazor
+open System
+open System.Web.Compilation
+open System.Web.Mvc
+open System.Web.WebPages.Razor
+
+type PreApplicationStartCode() =
+ static let mutable startWasCalled = false
+
+ static member Start() =
+ if (not startWasCalled) then
+ startWasCalled <- true
+
+ BuildProvider.RegisterBuildProvider(".fshtml", typeof<RazorBuildProvider>)
+ FSharpRazorCodeLanguage.Install();
+ ViewEngines.Engines.Add(new FSRazorViewEngine());
@@ -7,7 +7,7 @@ open System.Web.Razor.Parser
type FSharpRazorCodeLanguage() =
inherit RazorCodeLanguage()
- static do
+ static member Install() =
RazorCodeLanguage.Languages.Add("fshtml", new FSharpRazorCodeLanguage())
override x.LanguageName

0 comments on commit e5e6129

Please sign in to comment.