CodeGeneratorOptions 类

定义

表示代码生成器使用的一组选项。

public ref class CodeGeneratorOptions
public class CodeGeneratorOptions
type CodeGeneratorOptions = class
Public Class CodeGeneratorOptions
继承
CodeGeneratorOptions

示例

// Creates a new CodeGeneratorOptions.
CodeGeneratorOptions^ genOptions = gcnew CodeGeneratorOptions;

// Sets a value indicating that the code generator should insert blank lines between type members.
genOptions->BlankLinesBetweenMembers = true;

// Sets the style of bracing format to use: either S"Block" to start a
// bracing block on the same line as the declaration of its container, or
// S"C" to start the bracing for the block on the following line.
genOptions->BracingStyle = "C";

// Sets a value indicating that the code generator should not append an else,
// catch or finally block, including brackets, at the closing line of a preceeding if or try block.
genOptions->ElseOnClosing = false;

// Sets the String* to indent each line with.
genOptions->IndentString = "    ";

// Uses the CodeGeneratorOptions indexer property to set an
// example Object* to the type's String*-keyed ListDictionary.
// Custom ICodeGenerator* implementations can use objects
// in this dictionary to customize process behavior.
genOptions[ "CustomGeneratorOptionStringExampleID" ] = "BuildFlags: /A /B /C /D /E";
// Creates a new CodeGeneratorOptions.
CodeGeneratorOptions genOptions = new CodeGeneratorOptions();

// Sets a value indicating that the code generator should insert blank lines between type members.
genOptions.BlankLinesBetweenMembers = true;

// Sets the style of bracing format to use: either "Block" to start a
// bracing block on the same line as the declaration of its container, or
// "C" to start the bracing for the block on the following line.
genOptions.BracingStyle = "C";

// Sets a value indicating that the code generator should not append an else,
// catch or finally block, including brackets, at the closing line of a preceeding if or try block.
genOptions.ElseOnClosing = false;

// Sets the string to indent each line with.
genOptions.IndentString = "    ";

// Uses the CodeGeneratorOptions indexer property to set an
// example object to the type's string-keyed ListDictionary.
// Custom ICodeGenerator implementations can use objects
// in this dictionary to customize process behavior.
genOptions["CustomGeneratorOptionStringExampleID"] = "BuildFlags: /A /B /C /D /E";
' Creates a new CodeGeneratorOptions.
Dim genOptions As New CodeGeneratorOptions()

' Sets a value indicating that the code generator should insert blank lines between type members.
genOptions.BlankLinesBetweenMembers = True

' Sets the style of bracing format to use: either "Block" to start a
' bracing block on the same line as the declaration of its container, or 
' "C" to start the bracing for the block on the following line.
genOptions.BracingStyle = "C"

' Sets a value indicating that the code generator should not append an else, 
' catch or finally block, including brackets, at the closing line of a preceeding if or try block.
genOptions.ElseOnClosing = False

' Sets the string to indent each line with.
genOptions.IndentString = "    "

' Uses the CodeGeneratorOptions indexer property to set an
' example object to the type's string-keyed ListDictionary.
' Custom ICodeGenerator implementations can use objects 
' in this dictionary to customize process behavior.
genOptions("CustomGeneratorOptionStringExampleID") = "BuildFlags: /A /B /C /D /E"

注解

CodeGeneratorOptions 传递给实现的代码生成方法 ICodeGenerator ,以指定代码生成期间使用的选项。

属性 IndentString 指定要用于每个间距缩进的字符串。 属性 BracingStyle 指定大括号的放置样式,指示代码块的边界。 属性ElseOnClosing指定是否在每个 if 或 块的结束行追加 、 elsecatchfinallytry 块,包括括号。 属性 BlankLinesBetweenMembers 指定是否在成员之间插入空白行。

实现 ICodeGenerator 可以提供自定义代码生成选项,你可以使用字典索引器设置或将数据传递给 Item[] 这些选项,代码生成器可以搜索这些选项来查找其他代码生成选项。

注意

此类包含应用于所有成员的类级别的链接需求和继承需求。 SecurityException当直接调用方或派生类没有完全信任权限时,将引发 。 有关安全要求的详细信息,请参阅 链接需求继承需求

构造函数

CodeGeneratorOptions()

初始化 CodeGeneratorOptions 类的新实例。

属性

BlankLinesBetweenMembers

获取或设置一个值,该值指示是否在成员之间插入空行。

BracingStyle

获取或设置用于大括号的样式。

ElseOnClosing

获取或设置一个值,该值指示是否在前面每个 elsecatch 块的结束行处追加 finallyiftry 块(包括括号)。

IndentString

获取或设置用于缩进的字符串。

Item[String]

获取或设置指定索引处的对象。

VerbatimOrder

获取或设置一个值,该值指示是否按成员在成员集合中出现的顺序生成成员。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于