George J.'s profile“Daily Cycle”PhotosBlogLists Tools Help

“Daily Cycle”

Personal notes on developing...
6/8/2009

FreeTextBoxWrapper for Community Server v2.1 & v2007 (Refresh)

It has been a while, since I have posted something about Community Server. Although I have received quite a lot requests, about refreshing FreeTextboxWrapper for CS v2.1 and CS v2007 controls, to the latest version of FreeTextBox (v6.2.2), in order to work correctly with newer browsers (Safari, Chrome, IE7 & IE8).

Well, here they are:

  • The new version of FreeTextBox is included and changes to JavaScript files to support the new FreeTextBox functionality.

del.icio.us Tags: ,

2/15/2009

SubSonic v3’s T4 Templates, Part 3

About a month ago, I created a first version of T4 templates for SubSonic v3 using T4Toolbox. They started as a fun way to learn using T4 transformation. Now, these templates are now intergraded in SubSonic v3 source.

If you are fan of SubSonic, or not, if you want to learn more about T4 transformation and how to use in a real life application, I suggest you download SubSonic v3 source and give it a try...

Happy transforming!

del.icio.us Tags: ,

T4 templates and include files

It true that Microsoft provides no support for .tt template editing in Visual Studio 2008. They don’t plan to include this functionality in Visual Studio 2010 either – see feature request in Microsoft Connect. If Clarius Consulting hadn’t released their T4 Editor, there would be no support for editing T4 templates at all.

I have spend many hours lately in order to master T4 template creation. The most annoying thing about T4 templates, is that they work: TextTemplatingFileGenerator tool, the tool responsible transforming T4 templates to text artifacts, has no clue if a .tt file is a standalone template or an include template file. The tool transforms every file, without exception. When creating multi-file templates, this is really annoying – you get thousands of errors, which don’t really exist. When you are in the middle of template creation, this is really confusing.

How can you deal with this?

Actually there is only one solution: use .tt extension only for stand alone templates, or the starting template of multi-file template. Use an other extension, let’s say .ttinclude extension, for all other template files. TextTemplatingFileGenerator tool is not assigned as “Custom Tool” in the new extension, so transformation by default is disabled.

This looks nice, but .ttinclude extension, is not recognized as a known extension by Visual Studio or Clarius T4 Editor. You will get rid of the errors that are really annoying, but you loose all this nice functionality that Clarius T4 Editor provides. The good news is that you can deal with this, adding just two entries in your registry:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.ttinclude]
@="VisualStudio.TextTemplating.1.2"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Languages\File Extensions\.ttinclude]
@="{4217b9d4-cd01-4b28-bc12-e289a19ecc6d}"

The first one, provides a type for .ttinclude extension, and a icon to recognize the files. The second one, makes sure that Clarius T4 editor, recognizes .ttinclude extension as a T4 template, and provides T4 template editing.

Happy transforming!

del.icio.us Tags: ,
1/26/2009

SubSonic v3’s T4 Templates, Part 2

It’s only been two weeks I’ve playing around with T4 templates. Most of the time is spent in learning how to debug them, and how to schema databases using different database providers. I have just created the fourth version of SubSonic v3’s T4 templates. You can read a recent post, how to use them.

del.icio.us Tags: ,
1/17/2009

T4 templates using own project .config file

One of the first problem one faces, as soon as he decides to include T4 templates in a project, is how to access .config file of the project. Most of the times .config files are used to store information as connection strings, as well as, other application wide settings, critical to the application. When a T4 template is transformed, it is not run under the context of the project it belongs; the context it runs is the context of the utility that performs the text transformation. Most of the times the utility is TextTemplatingFileGenerator.exe.

The need to access information from app.config from T4 templates, drive me create a T4 template include file, that gives me access to app.config information the same way as ConfigurationManager object. You can find this file here:

I also included in the archive, a T4 template that demonstrate its usage; it’s easy to instantiate the object:

    IServiceProvider hostServiceProvider = (IServiceProvider)this.Host;
    SettingsManager config = new SettingsManager(hostServiceProvider);

Then it’s easy to read the configuration from the project:

    this.ClearIndent();
    this.WriteLine("Namespace   : {0}", config.Namespace);
    this.WriteLine("AssemblyName: {0}", config.AssemblyName);
    this.WriteLine("ProjectPath : {0}", config.ProjectPath);
    this.WriteLine("ConfigPath  : {0}", config.ConfigPath);
    this.WriteLine("Is App      : {0}", config.IsApplication);
    this.WriteLine("Is WebApp   : {0}", config.IsWebApplication);
	
	// Display each ConnectionStringSettings.
    this.WriteLine("");
    this.WriteLine("ConnectionStrings:");
    this.PushIndent("\t");
	foreach (ConnectionStringSettings connectionstringentry in config.ConnectionStrings)
	{
		this.WriteLine("Name: {0}, ConnectionString: {1}, ProviderName: {2}", connectionstringentry.Name, connectionstringentry.ConnectionString, connectionstringentry.ProviderName);
	}
    this.PopIndent();
    this.WriteLine("");
	
	// Display each KeyValueConfigurationElement.
    this.WriteLine("ApplicationSettings:");
    this.PushIndent("\t");
	foreach (KeyValueConfigurationElement keyValueElement in config.AppSettings)
	{
		this.WriteLine("Key: {0}, Value: {1}", keyValueElement.Key, keyValueElement.Value);
	}
    this.PopIndent();
    this.WriteLine("");

Hope you find the template useful…

del.icio.us Tags: ,
 

Search

Loading...

Keyword Cloud

Loading...