Extending SubSonic Generator

subsonic

Is it possible to extend the SubSonic generator without modifying it's code?
I would like to add my own custom methods that i can use inside the templates. Somthing similair like the Utility.GetVariableType method.

Best Answer

You can't extend the built in templates, but you can replace them with your own templates without changing SubSonic.dll. See the templateDirectory parameter here: http://subsonicproject.com/docs/Generated_Classes/#Customizing_Active_Record

An example configuration would be:

<SubSonicService defaultProvider="Northwind" enableTrace="true"
    templateDirectory="C:\Program Files\SubSonic\SubSonic 2.0.3\Templates\MVC">
    <providers>
      <clear/>
      <add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic"
       connectionStringName="Northwind" generatedNamespace="Northwind"/>
    </providers>
  </SubSonicService>

You can get the current version of the built-in ActiveRecord templates from here.