(CodeGen)如何在生成的代码中嵌套命名空间? [英] (CodeGen) How to nest namespaces in generated code?

查看:83
本文介绍了(CodeGen)如何在生成的代码中嵌套命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行时使用System.CodeDom生成一个类,例如



I am generating a class at run time using System.CodeDom e.g.

Imports System.CodeDom


 'add the imports namespace
 Dim identityGroupInterfaceRet As New CodeCompileUnit()
 'put the namespace hierarchy in...model name..
 Dim modelNamespace As CodeNamespace = New CodeNamespace("Model")





我如何在这一个中嵌套另一个命名空间?



How would I go about nesting another namespace inside this one?

推荐答案

根据此主题 [ ^ ]:

According to this thread[^] on MSDN:



嵌套命名空间只是语法糖编译器。就运行时而言,名称空间不是分层的。它相当于将新的CodeNamespace(ABCD)添加到 CodeCompileUnit.Namespaces


A "nested" namespace is just syntactical sugar by the compiler. As far as the runtime is concerned, namespaces are not hierarchical. It is equivalent to adding a new CodeNamespace("A.B.C.D") to your CodeCompileUnit.Namespaces.


这篇关于(CodeGen)如何在生成的代码中嵌套命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆