CodeDomProvider.GenerateCodeFromNamespace(CodeNamespace, TextWriter, CodeGeneratorOptions) 方法

定义

为指定的代码文档对象模型 (CodeDOM) 命名空间生成代码,并使用指定的选项将代码发送到指定的文本编写器。Generates code for the specified Code Document Object Model (CodeDOM) namespace and sends it to the specified text writer, using the specified options.

public:
 virtual void GenerateCodeFromNamespace(System::CodeDom::CodeNamespace ^ codeNamespace, System::IO::TextWriter ^ writer, System::CodeDom::Compiler::CodeGeneratorOptions ^ options);
public virtual void GenerateCodeFromNamespace (System.CodeDom.CodeNamespace codeNamespace, System.IO.TextWriter writer, System.CodeDom.Compiler.CodeGeneratorOptions options);
abstract member GenerateCodeFromNamespace : System.CodeDom.CodeNamespace * System.IO.TextWriter * System.CodeDom.Compiler.CodeGeneratorOptions -> unit
override this.GenerateCodeFromNamespace : System.CodeDom.CodeNamespace * System.IO.TextWriter * System.CodeDom.Compiler.CodeGeneratorOptions -> unit
Public Overridable Sub GenerateCodeFromNamespace (codeNamespace As CodeNamespace, writer As TextWriter, options As CodeGeneratorOptions)

参数

codeNamespace
CodeNamespace

一个 CodeNamespace 对象,指示要为其生成代码的命名空间。A CodeNamespace object that indicates the namespace for which to generate code.

writer
TextWriter

输出代码将被发送到的 TextWriterThe 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 提供程序的方法返回的实现提供 CreateGeneratorIn 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.

适用于

另请参阅