forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSharpRazorCodeGenerator.cs
More file actions
42 lines (38 loc) · 1.65 KB
/
CSharpRazorCodeGenerator.cs
File metadata and controls
42 lines (38 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using ServiceStack.Razor.Templating;
using System.Web.Razor;
using System.Web.Razor.Parser.SyntaxTree;
namespace ServiceStack.Razor.Compilation.CSharp
{
/// <summary>
/// Defines a code generator that supports C# syntax.
/// </summary>
public partial class CSharpRazorCodeGenerator : System.Web.Razor.Generator.CSharpRazorCodeGenerator
{
/// <summary>
/// Initializes a new instance of the <see cref="CSharpRazorCodeGenerator"/> class.
/// </summary>
/// <param name="className">Name of the class.</param>
/// <param name="rootNamespaceName">Name of the root namespace.</param>
/// <param name="sourceFileName">Name of the source file.</param>
/// <param name="host">The host.</param>
/// <param name="strictMode">Flag to specify that this generator is running in struct mode.</param>
public CSharpRazorCodeGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host, bool strictMode)
: base(className, rootNamespaceName, sourceFileName, host)
{
StrictMode = strictMode;
}
/// <summary>
/// Gets whether the code generator is running in strict mode.
/// </summary>
public bool StrictMode { get; private set; }
/// <summary>
/// Visits an error generated through parsing.
/// </summary>
/// <param name="err">The error that was generated.</param>
public override void VisitError(RazorError err)
{
if (StrictMode)
throw new TemplateParsingException(err);
}
}
}