CodeDomProvider.GenerateCodeFromStatement(CodeStatement, TextWriter, CodeGeneratorOptions) 方法
定义
为指定的代码文档对象模型 (CodeDOM) 语句生成代码,并使用指定的选项将代码发送到指定的文本编写器。Generates code for the specified Code Document Object Model (CodeDOM) statement and sends it to the specified text writer, using the specified options.
public:
virtual void GenerateCodeFromStatement(System::CodeDom::CodeStatement ^ statement, System::IO::TextWriter ^ writer, System::CodeDom::Compiler::CodeGeneratorOptions ^ options);
public virtual void GenerateCodeFromStatement (System.CodeDom.CodeStatement statement, System.IO.TextWriter writer, System.CodeDom.Compiler.CodeGeneratorOptions options);
abstract member GenerateCodeFromStatement : System.CodeDom.CodeStatement * System.IO.TextWriter * System.CodeDom.Compiler.CodeGeneratorOptions -> unit
override this.GenerateCodeFromStatement : System.CodeDom.CodeStatement * System.IO.TextWriter * System.CodeDom.Compiler.CodeGeneratorOptions -> unit
Public Overridable Sub GenerateCodeFromStatement (statement As CodeStatement, writer As TextWriter, options As CodeGeneratorOptions)
参数
- statement
- CodeStatement
CodeStatement,包含要为其生成代码的 CodeDOM 元素。A CodeStatement containing the CodeDOM elements for which to generate code.
- writer
- TextWriter
输出代码将被发送到的 TextWriter。The TextWriter to which output code is sent.
- options
- CodeGeneratorOptions
CodeGeneratorOptions,指示用于生成代码的选项。A CodeGeneratorOptions that indicates the options to use for generating code.
例外
此方法和 CreateGenerator() 方法均不在派生类中重写。Neither this method nor the CreateGenerator() method is overridden in a derived class.
注解
备注
在 .NET Framework 版本1.0 和1.1 中,此方法由 ICodeGenerator 提供程序的方法返回的实现提供 CreateGenerator 。In the .NET Framework versions 1.0 and 1.1, this method is provided by the ICodeGenerator implementation that is returned by the CreateGenerator method of the provider. 在版本2.0 中,可以直接在代码提供程序上调用此方法,即使代码提供程序未重写此方法。In version 2.0, this method can be called directly on the code provider even if it is not overridden by the code provider. 如果代码提供程序不重写此方法,则 ICodeGenerator 由基类调用实现。If the code provider does not override this method, the ICodeGenerator implementation is called by the base class.
继承者说明
如果重写此方法,则不能调用基类的相应方法。If you override this method, you must not call the corresponding method of the base class. 基类方法使用已过时的方法在派生类中创建一个生成器, CreateGenerator() 以便与使用代码生成器的预先存在的提供程序兼容。The base-class method creates a generator in the derived class using the obsolete CreateGenerator() method for compatibility with preexisting providers that use code generators. 然后,基类方法调用实现中的等效方法 ICodeGenerator 来执行此函数。The base-class method then calls the equivalent method in the ICodeGenerator implementation to perform this function. NotImplementedException如果从不使用代码生成器的代码提供程序调用基类方法,则将收到。You will get a NotImplementedException if you call the base-class method from a code provider that does not use a code generator.