@@ -16,14 +16,14 @@ public class RazorEngine : IRazorEngine
1616 public IRazorEngineCompiledTemplate < T > Compile < T > ( string content , Action < IRazorEngineCompilationOptionsBuilder > builderAction = null ) where T : IRazorEngineTemplate
1717 {
1818 IRazorEngineCompilationOptionsBuilder compilationOptionsBuilder = new RazorEngineCompilationOptionsBuilder ( ) ;
19-
19+
2020 compilationOptionsBuilder . AddAssemblyReference ( typeof ( T ) . Assembly ) ;
2121 compilationOptionsBuilder . Inherits ( typeof ( T ) ) ;
2222
2323 builderAction ? . Invoke ( compilationOptionsBuilder ) ;
2424
2525 MemoryStream memoryStream = this . CreateAndCompileToStream ( content , compilationOptionsBuilder . Options ) ;
26-
26+
2727 return new RazorEngineCompiledTemplate < T > ( memoryStream ) ;
2828 }
2929
@@ -36,7 +36,7 @@ public IRazorEngineCompiledTemplate Compile(string content, Action<IRazorEngineC
3636 {
3737 IRazorEngineCompilationOptionsBuilder compilationOptionsBuilder = new RazorEngineCompilationOptionsBuilder ( ) ;
3838 compilationOptionsBuilder . Inherits ( typeof ( RazorEngineTemplateBase ) ) ;
39-
39+
4040 builderAction ? . Invoke ( compilationOptionsBuilder ) ;
4141
4242 MemoryStream memoryStream = this . CreateAndCompileToStream ( content , compilationOptionsBuilder . Options ) ;
@@ -48,8 +48,8 @@ public Task<IRazorEngineCompiledTemplate> CompileAsync(string content, Action<IR
4848 {
4949 return Task . Factory . StartNew ( ( ) => this . Compile ( content : content , builderAction : builderAction ) ) ;
5050 }
51-
52- private MemoryStream CreateAndCompileToStream ( string templateSource , RazorEngineCompilationOptions options )
51+
52+ protected virtual MemoryStream CreateAndCompileToStream ( string templateSource , RazorEngineCompilationOptions options )
5353 {
5454 templateSource = this . WriteDirectives ( templateSource , options ) ;
5555
@@ -64,7 +64,7 @@ private MemoryStream CreateAndCompileToStream(string templateSource, RazorEngine
6464 string fileName = Path . GetRandomFileName ( ) ;
6565
6666 RazorSourceDocument document = RazorSourceDocument . Create ( templateSource , fileName ) ;
67-
67+
6868 RazorCodeDocument codeDocument = engine . Process (
6969 document ,
7070 null ,
@@ -105,7 +105,7 @@ private MemoryStream CreateAndCompileToStream(string templateSource, RazorEngine
105105 return memoryStream ;
106106 }
107107
108- private string WriteDirectives ( string content , RazorEngineCompilationOptions options )
108+ protected virtual string WriteDirectives ( string content , RazorEngineCompilationOptions options )
109109 {
110110 StringBuilder stringBuilder = new StringBuilder ( ) ;
111111 stringBuilder . AppendLine ( $ "@inherits { options . Inherits } ") ;
0 commit comments