共用方式為


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會指定是否要在或 iftry 區塊的結尾行附加 elsecatchfinally 區塊,包括方括弧。 屬性 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)

適用於