May 25, 2021 CodeSmith
The .Net class library can be referenced in the CodeSmith template, and different from a normal .Net project, references to the .Net library are implemented not through the Add reference of the project, but by indicating the Assembly to reference in the code template.
For example, by referencing CodeSmith's own CodeSmith.Custom .dll, you can use the following statement:
<%@ Assembly Name="CodeSmith.CustomProperties" %>
After referring to the appropriate Assembly, similar to the common C# language, for the .Net class used, you need to introduce the namespace in which the class resyse through Import.
CodeSmith, for example, uses Tutorial (9): The Progress object introduces System.Threading, where the Thread class is located
<%@ Import Namespace="System.Threading" %>
In addition, if you need to introduce some source code (such as some common code) into your code template, you can use include, for example:
<!– #include file="CommonScript.cs" –>
The method of sharing code, in addition to the include method used above, can also be implemented by setting the Src properties of CodeTemplate and Assembly.