forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetVBOptionCodeGenerator.cs
More file actions
44 lines (36 loc) · 1.5 KB
/
Copy pathSetVBOptionCodeGenerator.cs
File metadata and controls
44 lines (36 loc) · 1.5 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
43
44
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Web.Razor.Parser.SyntaxTree;
namespace System.Web.Razor.Generator
{
public class SetVBOptionCodeGenerator : SpanCodeGenerator
{
public static readonly string StrictCodeDomOptionName = "AllowLateBound";
public static readonly string ExplicitCodeDomOptionName = "RequireVariableDeclaration";
public SetVBOptionCodeGenerator(string optionName, bool value)
{
OptionName = optionName;
Value = value;
}
// CodeDOM Option Name, which is NOT the same as the VB Option Name
public string OptionName { get; private set; }
public bool Value { get; private set; }
public static SetVBOptionCodeGenerator Strict(bool onOffValue)
{
// Strict On = AllowLateBound Off
return new SetVBOptionCodeGenerator(StrictCodeDomOptionName, !onOffValue);
}
public static SetVBOptionCodeGenerator Explicit(bool onOffValue)
{
return new SetVBOptionCodeGenerator(ExplicitCodeDomOptionName, onOffValue);
}
public override void GenerateCode(Span target, CodeGeneratorContext context)
{
context.CompileUnit.UserData[OptionName] = Value;
}
public override string ToString()
{
return "Option:" + OptionName + "=" + Value;
}
}
}