CodeGeneratorOptions 类

定义

表示代码生成器使用的一组选项。Represents a set of options used by a code generator.

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 ,以指定在代码生成期间使用的选项。CodeGeneratorOptions is passed to the code generation methods of an ICodeGenerator implementation to specify options used during code generation.

IndentString属性指定用于每个间距缩进的字符串。The IndentString property specifies the string to use for each spacing indentation. BracingStyle属性为指示代码块边界的大括号指定位置样式。The BracingStyle property specifies the placement style for braces indicating the boundaries of code blocks. ElseOnClosing属性指定是否 else catch finally 在每个或块的结束行追加、或块,包括方括号 if tryThe ElseOnClosing property specifies whether to append an else, catch, or finally block, including brackets, at the closing line of each if or try block. BlankLinesBetweenMembers属性指定是否在成员之间插入空行。The BlankLinesBetweenMembers property specifies whether to insert blank lines between members.

ICodeGenerator实现可提供自定义代码生成选项,您可以使用字典索引器来设置数据或将数据传递到 Item[] ,代码生成器可以在该索引器中搜索以查找其他代码生成选项。An ICodeGenerator implementation can provide custom code generation options which you can set or pass data to using the Item[] dictionary indexer, which a code generator can search through to locate additional code generation options.

备注

此类包含应用于所有成员的类级别的链接要求和继承要求。This class contains a link demand and an inheritance demand at the class level that applies to all members. SecurityException当直接调用方或派生类不具有完全信任权限时,将引发。A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. 有关安全要求的详细信息,请参阅 链接要求继承要求For details about security demands, see Link Demands and Inheritance Demands.

构造函数

CodeGeneratorOptions()

初始化 CodeGeneratorOptions 类的新实例。Initializes a new instance of the CodeGeneratorOptions class.

属性

BlankLinesBetweenMembers

获取或设置一个值,该值指示是否在成员之间插入空行。Gets or sets a value indicating whether to insert blank lines between members.

BracingStyle

获取或设置用于大括号的样式。Gets or sets the style to use for bracing.

ElseOnClosing

获取或设置一个值,该值指示是否在前面每个 elsecatch 块的结束行处追加 finallyiftry 块(包括括号)。Gets or sets a value indicating whether to append an else, catch, or finally block, including brackets, at the closing line of each previous if or try block.

IndentString

获取或设置用于缩进的字符串。Gets or sets the string to use for indentations.

Item[String]

获取或设置指定索引处的对象。Gets or sets the object at the specified index.

VerbatimOrder

获取或设置一个值,该值指示是否按成员在成员集合中出现的顺序生成成员。Gets or sets a value indicating whether to generate members in the order in which they occur in member collections.

方法

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于