码迷,mamicode.com
首页 > 其他好文 > 详细

T4 assembly

时间:2014-11-27 15:54:23      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:io   ar   sp   for   on   ad   ef   as   line   

In a T4 template the executing assembly is not yours but one from the T4 engine.

To access types from your assemblies, you have to perform the following steps:

  1. Add a reference to your assembly to the template. Put that at the top of it:

    <#@ assembly name="$(SolutionDir)<Project>\bin\Debug\<Project>.dll" #>
    
  2. Import the namespace of your assembly. Put that somewhere below the previous line:

    <#@ import namespace="<Project>.<Namespace>" #>
    
  3. To access the types in this assembly, pick one of them and get the assembly from it:

    var assembly = typeof(<Type in assembly>).Assembly;
    var types = assembly.GetTypes()
                        .Where(t => String.Equals(
                            t.Namespace,
                            "RepoLib.Rts.Web.Plugins.Profiler.Models",
                            StringComparison.Ordinal))
                        .ToArray();

T4 assembly

标签:io   ar   sp   for   on   ad   ef   as   line   

原文地址:http://www.cnblogs.com/zwei1121/p/4126311.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!