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. finally else catch if屬性會指定是否要在每個或try區塊的結尾行附加、或區塊, 包括括弧。 ElseOnClosingThe 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[String]來設定或將資料傳遞給它, 而程式碼產生器可以搜尋以找出額外的程式碼產生選項。An ICodeGenerator implementation can provide custom code generation options which you can set or pass data to using the Item[String] 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. 當立即呼叫端或衍生類別沒有完全信任許可權時,就會擲回。SecurityExceptionA 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 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

安全性

LinkDemand
針對立即呼叫者的完全信任的。for full trust for the immediate caller. 此成員無法由部分信任程式碼使用。This class cannot be used by partially trusted code.

InheritanceDemand
適用於繼承者的完全信任的。for full trust for inheritors. 此類別無法由部分信任程式碼繼承。This class cannot be inherited by partially trusted code.

適用於