Rediger

Del via


CodeGenerator Class

Definition

Provides an example implementation of the ICodeGenerator interface. This class is abstract.

public ref class CodeGenerator abstract : System::CodeDom::Compiler::ICodeGenerator
public abstract class CodeGenerator : System.CodeDom.Compiler.ICodeGenerator
type CodeGenerator = class
    interface ICodeGenerator
Public MustInherit Class CodeGenerator
Implements ICodeGenerator
Inheritance
CodeGenerator
Derived
Implements

Remarks

This is a useful base class for code generators to derive from. Code generators are capable of rendering source code in a specific language according to the structure of a Code Document Object Model (CodeDOM) graph. This class provides many functions and methods to generate specific types of code from a CodeDOM graph.

Note

This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands.

Constructors

CodeGenerator()

Initializes a new instance of the CodeGenerator class.

Properties

CurrentClass

Gets the code type declaration for the current class.

CurrentMember

Gets the current member of the class.

CurrentMemberName

Gets the current member name.

CurrentTypeName

Gets the current class name.

Indent

Gets or sets the amount of spaces to indent each indentation level.

IsCurrentClass

Gets a value indicating whether the current object being generated is a class.

IsCurrentDelegate

Gets a value indicating whether the current object being generated is a delegate.

IsCurrentEnum

Gets a value indicating whether the current object being generated is an enumeration.

IsCurrentInterface

Gets a value indicating whether the current object being generated is an interface.

IsCurrentStruct

Gets a value indicating whether the current object being generated is a value type or struct.

NullToken

Gets the token that represents null.

Options

Gets the options to be used by the code generator.

Output

Gets the text writer to use for output.

Methods

ContinueOnNewLine(String)

Generates a line-continuation character and outputs the specified string on a new line.

CreateEscapedIdentifier(String)

Creates an escaped identifier for the specified value.

CreateValidIdentifier(String)

Creates a valid identifier for the specified value.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GenerateArgumentReferenceExpression(CodeArgumentReferenceExpression)

Generates code for the specified argument reference expression.

GenerateArrayCreateExpression(CodeArrayCreateExpression)

Generates code for the specified array creation expression.

GenerateArrayIndexerExpression(CodeArrayIndexerExpression)

Generates code for the specified array indexer expression.

GenerateAssignStatement(CodeAssignStatement)

Generates code for the specified assignment statement.

GenerateAttachEventStatement(CodeAttachEventStatement)

Generates code for the specified attach event statement.

GenerateAttributeDeclarationsEnd(CodeAttributeDeclarationCollection)

Generates code for the specified attribute block end.

GenerateAttributeDeclarationsStart(CodeAttributeDeclarationCollection)

Generates code for the specified attribute block start.

GenerateBaseReferenceExpression(CodeBaseReferenceExpression)

Generates code for the specified base reference expression.

GenerateBinaryOperatorExpression(CodeBinaryOperatorExpression)

Generates code for the specified binary operator expression.

GenerateCastExpression(CodeCastExpression)

Generates code for the specified cast expression.

GenerateCodeFromMember(CodeTypeMember, TextWriter, CodeGeneratorOptions)

Generates code for the specified class member using the specified text writer and code generator options.

GenerateComment(CodeComment)

Generates code for the specified comment.

GenerateCommentStatement(CodeCommentStatement)

Generates code for the specified comment statement.

GenerateCommentStatements(CodeCommentStatementCollection)

Generates code for the specified comment statements.

GenerateCompileUnit(CodeCompileUnit)

Generates code for the specified compile unit.

GenerateCompileUnitEnd(CodeCompileUnit)

Generates code for the end of a compile unit.

GenerateCompileUnitStart(CodeCompileUnit)

Generates code for the start of a compile unit.

GenerateConditionStatement(CodeConditionStatement)

Generates code for the specified conditional statement.

GenerateConstructor(CodeConstructor, CodeTypeDeclaration)

Generates code for the specified constructor.

GenerateDecimalValue(Decimal)

Generates code for the specified decimal value.

GenerateDefaultValueExpression(CodeDefaultValueExpression)

Generates code for the specified reference to a default value.

GenerateDelegateCreateExpression(CodeDelegateCreateExpression)

Generates code for the specified delegate creation expression.

GenerateDelegateInvokeExpression(CodeDelegateInvokeExpression)

Generates code for the specified delegate invoke expression.

GenerateDirectionExpression(CodeDirectionExpression)

Generates code for the specified direction expression.

GenerateDirectives(CodeDirectiveCollection)

Generates code for the specified code directives.

GenerateDoubleValue(Double)

Generates code for a double-precision floating point number.

GenerateEntryPointMethod(CodeEntryPointMethod, CodeTypeDeclaration)

Generates code for the specified entry point method.

GenerateEvent(CodeMemberEvent, CodeTypeDeclaration)

Generates code for the specified event.

GenerateEventReferenceExpression(CodeEventReferenceExpression)

Generates code for the specified event reference expression.

GenerateExpression(CodeExpression)

Generates code for the specified code expression.

GenerateExpressionStatement(CodeExpressionStatement)

Generates code for the specified expression statement.

GenerateField(CodeMemberField)

Generates code for the specified member field.

GenerateFieldReferenceExpression(CodeFieldReferenceExpression)

Generates code for the specified field reference expression.

GenerateGotoStatement(CodeGotoStatement)

Generates code for the specified goto statement.

GenerateIndexerExpression(CodeIndexerExpression)

Generates code for the specified indexer expression.

GenerateIterationStatement(CodeIterationStatement)

Generates code for the specified iteration statement.

GenerateLabeledStatement(CodeLabeledStatement)

Generates code for the specified labeled statement.

GenerateLinePragmaEnd(CodeLinePragma)

Generates code for the specified line pragma end.

GenerateLinePragmaStart(CodeLinePragma)

Generates code for the specified line pragma start.

GenerateMethod(CodeMemberMethod, CodeTypeDeclaration)

Generates code for the specified method.

GenerateMethodInvokeExpression(CodeMethodInvokeExpression)

Generates code for the specified method invoke expression.

GenerateMethodReferenceExpression(CodeMethodReferenceExpression)

Generates code for the specified method reference expression.

GenerateMethodReturnStatement(CodeMethodReturnStatement)

Generates code for the specified method return statement.

GenerateNamespace(CodeNamespace)

Generates code for the specified namespace.

GenerateNamespaceEnd(CodeNamespace)

Generates code for the end of a namespace.

GenerateNamespaceImport(CodeNamespaceImport)

Generates code for the specified namespace import.

GenerateNamespaceImports(CodeNamespace)

Generates code for the specified namespace import.

GenerateNamespaces(CodeCompileUnit)

Generates code for the namespaces in the specified compile unit.

GenerateNamespaceStart(CodeNamespace)

Generates code for the start of a namespace.

GenerateObjectCreateExpression(CodeObjectCreateExpression)

Generates code for the specified object creation expression.

GenerateParameterDeclarationExpression(CodeParameterDeclarationExpression)

Generates code for the specified parameter declaration expression.

GeneratePrimitiveExpression(CodePrimitiveExpression)

Generates code for the specified primitive expression.

GenerateProperty(CodeMemberProperty, CodeTypeDeclaration)

Generates code for the specified property.

GeneratePropertyReferenceExpression(CodePropertyReferenceExpression)

Generates code for the specified property reference expression.

GeneratePropertySetValueReferenceExpression(CodePropertySetValueReferenceExpression)

Generates code for the specified property set value reference expression.

GenerateRemoveEventStatement(CodeRemoveEventStatement)

Generates code for the specified remove event statement.

GenerateSingleFloatValue(Single)

Generates code for a single-precision floating point number.

GenerateSnippetCompileUnit(CodeSnippetCompileUnit)

Outputs the code of the specified literal code fragment compile unit.

GenerateSnippetExpression(CodeSnippetExpression)

Outputs the code of the specified literal code fragment expression.

GenerateSnippetMember(CodeSnippetTypeMember)

Outputs the code of the specified literal code fragment class member.

GenerateSnippetStatement(CodeSnippetStatement)

Outputs the code of the specified literal code fragment statement.

GenerateStatement(CodeStatement)

Generates code for the specified statement.

GenerateStatements(CodeStatementCollection)

Generates code for the specified statement collection.

GenerateThisReferenceExpression(CodeThisReferenceExpression)

Generates code for the specified this reference expression.

GenerateThrowExceptionStatement(CodeThrowExceptionStatement)

Generates code for the specified throw exception statement.

GenerateTryCatchFinallyStatement(CodeTryCatchFinallyStatement)

Generates code for the specified try-catch-finally statement.

GenerateTypeConstructor(CodeTypeConstructor)

Generates code for the specified class constructor.

GenerateTypeEnd(CodeTypeDeclaration)

Generates code for the specified end of the class.

GenerateTypeOfExpression(CodeTypeOfExpression)

Generates code for the specified type of expression.

GenerateTypeReferenceExpression(CodeTypeReferenceExpression)

Generates code for the specified type reference expression.

GenerateTypes(CodeNamespace)

Generates code for the specified namespace and the classes it contains.

GenerateTypeStart(CodeTypeDeclaration)

Generates code for the specified start of the class.

GenerateVariableDeclarationStatement(CodeVariableDeclarationStatement)

Generates code for the specified variable declaration statement.

GenerateVariableReferenceExpression(CodeVariableReferenceExpression)

Generates code for the specified variable reference expression.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetTypeOutput(CodeTypeReference)

Gets the name of the specified data type.

IsValidIdentifier(String)

Gets a value indicating whether the specified value is a valid identifier.

IsValidLanguageIndependentIdentifier(String)

Gets a value indicating whether the specified string is a valid identifier.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OutputAttributeArgument(CodeAttributeArgument)

Outputs an argument in an attribute block.

OutputAttributeDeclarations(CodeAttributeDeclarationCollection)

Generates code for the specified attribute declaration collection.

OutputDirection(FieldDirection)

Generates code for the specified FieldDirection.

OutputExpressionList(CodeExpressionCollection, Boolean)

Generates code for the specified expression list.

OutputExpressionList(CodeExpressionCollection)

Generates code for the specified expression list.

OutputFieldScopeModifier(MemberAttributes)

Outputs a field scope modifier that corresponds to the specified attributes.

OutputIdentifier(String)

Outputs the specified identifier.

OutputMemberAccessModifier(MemberAttributes)

Generates code for the specified member access modifier.

OutputMemberScopeModifier(MemberAttributes)

Generates code for the specified member scope modifier.

OutputOperator(CodeBinaryOperatorType)

Generates code for the specified operator.

OutputParameters(CodeParameterDeclarationExpressionCollection)

Generates code for the specified parameters.

OutputType(CodeTypeReference)

Generates code for the specified type.

OutputTypeAttributes(TypeAttributes, Boolean, Boolean)

Generates code for the specified type attributes.

OutputTypeNamePair(CodeTypeReference, String)

Generates code for the specified object type and name pair.

QuoteSnippetString(String)

Converts the specified string by formatting it with escape codes.

Supports(GeneratorSupport)

Gets a value indicating whether the specified code generation support is provided.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
ValidateIdentifier(String)

Throws an exception if the specified string is not a valid identifier.

ValidateIdentifiers(CodeObject)

Attempts to validate each identifier field contained in the specified CodeObject or System.CodeDom tree.

Explicit Interface Implementations

ICodeGenerator.CreateEscapedIdentifier(String)

Creates an escaped identifier for the specified value.

ICodeGenerator.CreateValidIdentifier(String)

Creates a valid identifier for the specified value.

ICodeGenerator.GenerateCodeFromCompileUnit(CodeCompileUnit, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and outputs it to the specified text writer using the specified options.

ICodeGenerator.GenerateCodeFromExpression(CodeExpression, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) expression and outputs it to the specified text writer.

ICodeGenerator.GenerateCodeFromNamespace(CodeNamespace, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) namespace and outputs it to the specified text writer using the specified options.

ICodeGenerator.GenerateCodeFromStatement(CodeStatement, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) statement and outputs it to the specified text writer using the specified options.

ICodeGenerator.GenerateCodeFromType(CodeTypeDeclaration, TextWriter, CodeGeneratorOptions)

Generates code for the specified Code Document Object Model (CodeDOM) type declaration and outputs it to the specified text writer using the specified options.

ICodeGenerator.GetTypeOutput(CodeTypeReference)

Gets the type indicated by the specified CodeTypeReference.

ICodeGenerator.IsValidIdentifier(String)

Gets a value that indicates whether the specified value is a valid identifier for the current language.

ICodeGenerator.Supports(GeneratorSupport)

Gets a value indicating whether the generator provides support for the language features represented by the specified GeneratorSupport object.

ICodeGenerator.ValidateIdentifier(String)

Throws an exception if the specified value is not a valid identifier.

Applies to

See also