Partager via


CodeGeneratorOptions Classe

Définition

Représente un ensemble d’options utilisées par un générateur de code.

public ref class CodeGeneratorOptions
public class CodeGeneratorOptions
type CodeGeneratorOptions = class
Public Class CodeGeneratorOptions
Héritage
CodeGeneratorOptions

Exemples

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

Remarques

CodeGeneratorOptions est transmis aux méthodes de génération de code d’une ICodeGenerator implémentation pour spécifier les options utilisées pendant la génération de code.

La IndentString propriété spécifie la chaîne à utiliser pour chaque retrait d’espacement. La BracingStyle propriété spécifie le style de placement des accolades indiquant les limites des blocs de code. La ElseOnClosing propriété spécifie s’il faut ajouter un else, catchou finally un bloc, y compris des crochets, à la ligne fermante de chaque if ou try bloc. La BlankLinesBetweenMembers propriété spécifie s’il faut insérer des lignes vides entre les membres.

Une ICodeGenerator implémentation peut fournir des options de génération de code personnalisées que vous pouvez définir ou transmettre des données à l’aide de l’indexeur Item[] de dictionnaire, qu’un générateur de code peut rechercher pour rechercher des options de génération de code supplémentaires.

Note

Cette classe contient une demande de liaison et une demande d’héritage au niveau de la classe qui s’applique à tous les membres. Un SecurityException est levé lorsque l’appelant immédiat ou la classe dérivée n’a pas d’autorisation de confiance totale. Pour plus d’informations sur les demandes de sécurité, consultez Demandes de liaison et Demandes d’héritage.

Constructeurs

Nom Description
CodeGeneratorOptions()

Initialise une nouvelle instance de la classe CodeGeneratorOptions.

Propriétés

Nom Description
BlankLinesBetweenMembers

Obtient ou définit une valeur indiquant s’il faut insérer des lignes vides entre les membres.

BracingStyle

Obtient ou définit le style à utiliser pour l’accolade.

ElseOnClosing

Obtient ou définit une valeur indiquant s’il faut ajouter un else, catchou finally un bloc, y compris des crochets, à la ligne fermante de chaque bloc ou try précédentif.

IndentString

Obtient ou définit la chaîne à utiliser pour les retraits.

Item[String]

Obtient ou définit l’objet à l’index spécifié.

VerbatimOrder

Obtient ou définit une valeur indiquant s’il faut générer des membres dans l’ordre dans lequel ils se produisent dans les collections de membres.

Méthodes

Nom Description
Equals(Object)

Détermine si l’objet spécifié est égal à l’objet actuel.

(Hérité de Object)
GetHashCode()

Sert de fonction de hachage par défaut.

(Hérité de Object)
GetType()

Obtient la Type de l’instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Objectactuel.

(Hérité de Object)
ToString()

Retourne une chaîne qui représente l’objet actuel.

(Hérité de Object)

S’applique à