CodeGeneratorOptions Klasa
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Reprezentuje zestaw opcji używanych przez generator kodu.
public ref class CodeGeneratorOptions
public class CodeGeneratorOptions
type CodeGeneratorOptions = class
Public Class CodeGeneratorOptions
- Dziedziczenie
-
CodeGeneratorOptions
Przykłady
// 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"
Uwagi
CodeGeneratorOptions jest przekazywany do metod generowania kodu implementacji ICodeGenerator w celu określenia opcji używanych podczas generowania kodu.
Właściwość IndentString określa ciąg do użycia dla każdego wcięcia odstępów. Właściwość BracingStyle określa styl umieszczania nawiasów klamrowych wskazujących granice bloków kodu. Właściwość ElseOnClosing określa, czy należy dołączyć else
blok , catch
lub finally
, w tym nawiasy kwadratowe, w zamykającym wierszu każdego if
lub try
bloku. Właściwość BlankLinesBetweenMembers określa, czy należy wstawić puste wiersze między elementami członkowskimi.
Implementacja ICodeGenerator może zapewnić niestandardowe opcje generowania kodu, które można ustawić lub przekazać dane do za pomocą Item[] indeksatora słownika, który generator kodu może przeszukiwać w celu zlokalizowania dodatkowych opcji generowania kodu.
Uwaga
Ta klasa zawiera żądanie łącza i dziedziczenia na poziomie klasy stosowane do wszystkich składowych. Obiekt SecurityException jest zgłaszany, gdy bezpośredni obiekt wywołujący lub klasa pochodna nie ma uprawnienia pełnego zaufania. Aby uzyskać szczegółowe informacje na temat wymagań dotyczących zabezpieczeń, zobacz Link Demands and Inheritance Demands (Wymagania dotyczące linków i żądań dziedziczenia).
Konstruktory
CodeGeneratorOptions() |
Inicjuje nowe wystąpienie klasy CodeGeneratorOptions. |
Właściwości
BlankLinesBetweenMembers |
Pobiera lub ustawia wartość wskazującą, czy należy wstawić puste wiersze między elementami członkowskimi. |
BracingStyle |
Pobiera lub ustawia styl do użycia na potrzeby nawiasów klamrowych. |
ElseOnClosing |
Pobiera lub ustawia wartość wskazującą |
IndentString |
Pobiera lub ustawia ciąg do użycia dla wcięcia. |
Item[String] |
Pobiera lub ustawia obiekt w określonym indeksie. |
VerbatimOrder |
Pobiera lub ustawia wartość wskazującą, czy generować elementy członkowskie w kolejności, w jakiej występują w kolekcjach elementów członkowskich. |
Metody
Equals(Object) |
Określa, czy dany obiekt jest taki sam, jak bieżący obiekt. (Odziedziczone po Object) |
GetHashCode() |
Służy jako domyślna funkcja skrótu. (Odziedziczone po Object) |
GetType() |
Type Pobiera wartość bieżącego wystąpienia. (Odziedziczone po Object) |
MemberwiseClone() |
Tworzy płytkią kopię bieżącego Objectelementu . (Odziedziczone po Object) |
ToString() |
Zwraca ciąg reprezentujący bieżący obiekt. (Odziedziczone po Object) |
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla