Freigeben über


CodeGeneratorOptions-Klasse

Stellt einen von einem Code-Generator verwendeten Satz von Optionen dar.

Namespace: System.CodeDom.Compiler
Assembly: System (in system.dll)

Syntax

'Declaration
Public Class CodeGeneratorOptions
'Usage
Dim instance As CodeGeneratorOptions
public class CodeGeneratorOptions
public ref class CodeGeneratorOptions
public class CodeGeneratorOptions
public class CodeGeneratorOptions

Hinweise

CodeGeneratorOptions wird an die Methoden zur Codegenerierung einer ICodeGenerator-Implementierung übergeben, um während der Codegenerierung zu verwendende Optionen anzugeben.

Die IndentString-Eigenschaft gibt die für jeden Einzug zu verwendende Zeichenfolge an. Die BracingStyle-Eigenschaft gibt den Positionierungsstil für Klammern an, die die Begrenzungen von Codeblöcken angeben. Die ElseOnClosing-Eigenschaft gibt an, ob ein else-Block, ein catch-Block oder ein finally-Block einschließlich der Klammern an die abschließende Zeile jedes if-Blocks oder try-Blocks angefügt werden soll. Die BlankLinesBetweenMembers-Eigenschaft gibt an, ob leere Zeilen zwischen Membern eingefügt werden sollen.

Eine ICodeGenerator-Implementierung kann benutzerdefinierte Optionen zur Codegenerierung bereitstellen, die Sie festlegen und an die Sie Daten übergeben können, indem Sie den Item-Wörterbuchindexer verwenden, den ein Code-Generator zum Auffinden von zusätzlichen Optionen zur Codegenerierung durchsuchen kann.

Hinweis

Diese Klasse enthält auf Klassenebene einen Verknüpfungsaufruf und eine Vererbungsforderung, die für alle Member gelten. Eine SecurityException wird ausgelöst, wenn der direkte Aufrufer bzw. die abgeleitete Klasse nicht über voll vertrauenswürdige Berechtigung verfügen. Ausführliche Informationen über Sicherheitsforderungen finden Sie unter Verknüpfungsaufrufe und Vererbungsforderungen.

Beispiel

' 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"
// 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.
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";

.NET Framework-Sicherheit

Vererbungshierarchie

System.Object
  System.CodeDom.Compiler.CodeGeneratorOptions

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

CodeGeneratorOptions-Member
System.CodeDom.Compiler-Namespace