Bagikan melalui


CodeGeneratorOptions Kelas

Definisi

Mewakili sekumpulan opsi yang digunakan oleh generator kode.

public ref class CodeGeneratorOptions
public class CodeGeneratorOptions
type CodeGeneratorOptions = class
Public Class CodeGeneratorOptions
Warisan
CodeGeneratorOptions

Contoh

// 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"

Keterangan

CodeGeneratorOptions diteruskan ke metode pembuatan kode implementasi untuk menentukan opsi yang ICodeGenerator digunakan selama pembuatan kode.

Properti IndentString menentukan string yang akan digunakan untuk setiap indentasi penspasian. Properti BracingStyle menentukan gaya penempatan untuk kurung kurawal yang menunjukkan batas blok kode. Properti ElseOnClosing menentukan apakah akan menambahkan elseblok , , catchatau finally , termasuk tanda kurung siku, pada baris penutup masing-masing if atau try blok. Properti BlankLinesBetweenMembers menentukan apakah akan menyisipkan baris kosong antar anggota.

Implementasi ICodeGenerator dapat menyediakan opsi pembuatan kode kustom yang dapat Anda atur atau teruskan data ke menggunakan Item[] pengindeks kamus, yang dapat dicari generator kode untuk menemukan opsi pembuatan kode tambahan.

Catatan

Kelas ini berisi permintaan tautan dan permintaan warisan di tingkat kelas yang berlaku untuk semua anggota. SecurityException dilemparkan ketika pemanggil langsung atau kelas turunan tidak memiliki izin kepercayaan penuh. Untuk detail tentang tuntutan keamanan, lihat Permintaan Tautan dan Permintaan Warisan.

Konstruktor

CodeGeneratorOptions()

Menginisialisasi instans baru kelas CodeGeneratorOptions.

Properti

BlankLinesBetweenMembers

Mendapatkan atau menetapkan nilai yang menunjukkan apakah akan menyisipkan baris kosong antar anggota.

BracingStyle

Mendapatkan atau mengatur gaya yang akan digunakan untuk bracing.

ElseOnClosing

Mendapatkan atau menetapkan nilai yang menunjukkan apakah akan menambahkan elseblok , , catchatau finally , termasuk tanda kurung siku, di baris penutup setiap blok atau try sebelumnyaif.

IndentString

Mendapatkan atau mengatur string yang akan digunakan untuk indentasi.

Item[String]

Mendapatkan atau mengatur objek pada indeks yang ditentukan.

VerbatimOrder

Mendapatkan atau menetapkan nilai yang menunjukkan apakah akan menghasilkan anggota dalam urutan di mana mereka terjadi dalam koleksi anggota.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk