How to custom the class template in WCSF?

Mar 26, 2009 at 9:51 AM
The WCSF will help us to auto create presenter class, interface while creating a page. How can add some header information in a  created class such as create date, create time?
Mar 26, 2009 at 5:05 PM
Edited Mar 26, 2009 at 5:07 PM


To change the classes’ code, generated by the factory, you have 2 ways to do it:

1.       Modifying the T4 templates provided by the Guidance Package:

You will be able to find these in the ~\Microsoft Web Client Software Factory February 2008\WCSF Guidance Package\Templates\T4\View.CS folder. Then, you should open each of the *.t4 files and modify it as you want.

For example, to add the creation date time inside the Presenter Class’ code, you should open the ViewPresenter.cs.t4 file and add the following line at the beginning:

//Creation DateTime: <#= DateTime.Now.ToString() #>


2.       Modifying the Guidance Package:

Many times you cannot write the required text inside your class’ code modifying only the T4 templates, in this cases, you should modify some elements inside the Guidance Package (generally the recipes), and then, recompile and register this new Guidance Package version.


Take into account that it might not be easy to customize the Guidance Package, but it can be done after understanding how it works. The source code of the WCSF can be obtained after running an installer that comes with the downloaded factory.

Perhaps the following thread, in which Michael Puleio (p&p Dev Lead), explains how to customize the Guidance Package could be useful for you:

o   How do i customise WCSF to remove presenter layer


Below you can find a link to the GAT/GAX site, one of the main things you will need to understand and a requirement to customize the Guidance Package:

·         Guidance Automation Extensions and Guidance Automation Toolkit


Please let me know if this helps.


Damian Schenkelman

Mar 27, 2009 at 5:20 AM
I have tried the first solution, and it's good for me. If I want to display current assembly name and current user, how can I do?
Mar 27, 2009 at 9:04 PM


You can use something like this to display the current logged user:


            //CurrentUser: <#= System.Environment.UserName #>


Unfortunately, there is not a way to get the assembly name of the module with the current implementation of the Guidance Package, you will have to modify it to pass the assembly name as a parameter to the T4 template.

A possible workaround to avoid customize the Guidance Package is knowing that the Guidance Package sets the module’s assembly name the same as the module name, you can use the property ModuleName (that is accessible in the ViewPresenter T4 template in the default Guidance Package’s implementation) and add as suffix the “.dll” string. Take into the account that if you modify the module’s assembly name manually, the change will not be shown in the generated classes.

You can use something like this to implement the workaround:

//ModuleName: <#= this.ModuleName #>
//AssemblyName: <#= this.ModuleName #>.dll


Please, let me know if this helps.


Ezequiel Sculli

Mar 28, 2009 at 1:36 PM
Thanks, it works