zoukankan      html  css  js  c++  java
  • CodeSmith实用技巧(十三):使用CodeTemplateInfo对象

    CodeSmith中使用CodeTemplateInfo可以获取当前模版的一些信息:

    属性

    返回值

    CodeBehind   

    Gets the full path to the code-behind file for the template (or an empty string if there is no code-behind file).

    ContentHashCode

    Gets the hash code based on the template content and all template dependencies.  

    DateCreated

    Gets the date the template was created.

    DateModified

    Gets the date the template was modified.  

    Description

    Gets the description.  

    DirectoryName

    Gets the name of the directory the template is located in.  

    FileName

    Gets the name of the template file.  

    FullPath

    Gets the full path to the template.  

    Language

    Gets the template language.  

    TargetLanguage

    Gets the target language.  

    看一下一个具体的使用例子:

    <%@ CodeTemplate Language="VB" TargetLanguage="Text" Description="Demonstrates CodeTemplateInfo." %>
    <% DumpInfo() %>
    <script runat="template">
    Public Sub DumpInfo()
        Response.WriteLine(
    "Template:        {0}", Me.CodeTemplateInfo.FileName)
        Response.WriteLine(
    "Created:         {0}", Me.CodeTemplateInfo.DateCreated)
        Response.WriteLine(
    "Description:     {0}", Me.CodeTemplateInfo.Description)
        Response.WriteLine(
    "Location:        {0}", Me.CodeTemplateInfo.FullPath)
        Response.WriteLine(
    "Language:        {0}", Me.CodeTemplateInfo.Language)
        Response.WriteLine(
    "Target Language: {0}", Me.CodeTemplateInfo.TargetLanguage)
    End Sub
    </script>

    执行该模版输出如下(环境不同,输出也不同):

    Template:        CodeTemplateInfo.cst
    Created:         
    6/29/2005 8:54:19 PM
    Description:     Demonstrates CodeTemplateInfo.
    Location:        C:\Program Files\CodeSmith\v3.
    0\SampleTemplates\Test\CodeTemplateInfo.cst
    Language:        VB
    Target Language: Text
    支持TerryLee的创业产品Worktile
    Worktile,新一代简单好用、体验极致的团队协同、项目管理工具,让你和你的团队随时随地一起工作。完全免费,现在就去了解一下吧。
    https://worktile.com
  • 相关阅读:
    6.GC算法
    5.程序计算器、代码缓存、直接内存
    4.VM Stack(虚拟机栈)+ Native Method Stack(本地方法栈)
    3.Metaspace(元空间)
    2.Heap(堆区)
    1.JVM内存布局
    Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "goods_name")
    url参数由jsp传到controller乱码,直接修改tomcat就好了
    下拉框附带搜索框
    MyBatis if判断条件有特殊需求时的问题
  • 原文地址:https://www.cnblogs.com/Terrylee/p/306801.html
Copyright © 2011-2022 走看看