May 25, 2021 CodeSmith
The CodeTemplateInfo object provides some information about the code template file itself, such as the file name, source language, encoding method, and its supported properties are:
The property name | Describe |
---|---|
CodeBehind | The code-behind file name of the template or the template is an empty string when CodeBehind is not used |
ContentHashCode | Returns a Hash value for the code template |
DateCreated | Returns when the template was created |
DateModified | Returns when the template was modified |
Description | Return to the template description |
DirectoryName | Returns the directory where the template is located |
FileName | Returns the file name of the template |
FullPath | Returns the full path to the template |
Language | Returns the source language type of the template |
TargetLanguage | Returns the target language type generated by the template |
This example shows the above individual property values in the output file from the CodeTemplateInfo property object of the CodeTempalte object:
<%@ CodeTemplate Language="C#" TargetLanguage="Text"
Description="Demonstrates CodeTemplateInfo." %>
<% DumpInfo(); %>
<script runat="template">
public void DumpInfo()
{
Response.WriteLine("Template: {0}", CodeTemplateInfo.FileName);
Response.WriteLine("Created: {0}", CodeTemplateInfo.DateCreated);
Response.WriteLine("Description: {0}", CodeTemplateInfo.Description);
Response.WriteLine("Location: {0}", CodeTemplateInfo.FullPath);
Response.WriteLine("Language: {0}", CodeTemplateInfo.Language);
Response.WriteLine("Target Language: {0}", CodeTemplateInfo.TargetLanguage);
}
</script>
The results are as follows:
Template: CodeTemplateInfo.cst
Created: 6/01/2013 12:49:57 PM
Description: Demonstrates CodeTemplateInfo.
Location: D:\tmp\CodeTemplateInfoDemo\CodeTemplateInfoDemo\CodeTemplateInfo.cst
Language: C#
Target Language: Text
This example Downloads