How to output namespace in T4 templates?

前端 未结 6 812
無奈伤痛
無奈伤痛 2020-12-25 11:21

I have a T4 template for a class set up with TextTemplatingFileGenerator Custom Tool in Visual Studio:

<#@ template language=\"C#v3.5\" hostspecific=\"Tru         


        
6条回答
  •  [愿得一人]
    2020-12-25 11:34

    If you're using Visual Studio 2010, you can retrieve the namespace by checking the CallContext's "NamespaceHint" property.

    System.Runtime.Remoting.Messaging.CallContext.LogicalGetData("NamespaceHint");
    

提交回复
热议问题