I'm working on some code-generation stuff - using T4 RuntimTemplates.
I do have more than one template and I "store" them in an IEnumerable
list.
My problem is that I want to iterate through the templates using .WriteAllText()
which is a virtual method.
I thought, that it might be the easiest way to create an interface with the definition of .WriteAllText()
and declare it in the partial class..
public partial class SolutionTemplateRunTime : SolutionTemplateRunTimeBase, ICodegenerationTemplate
{
This works till I store or update the template ;-) . The partial class (the code behind cs) of the template gets updated and the interfaces declaration is gone.
public partial class SolutionTemplateRunTime : SolutionTemplateRunTimeBase
{
Is there a solution to handle that? Its kind of annoying to redeclare the interface whenever I update the template..
Hope you can help..
Greetz Iki
I think you're missing the point of partial
- the idea is that exactly the kind of changes you want to do are done in a separate file - one that isn't generated.
Just create a new cs
file, with a declaration like this:
public partial class SolutionTemplateRunTime : ICodegenerationTemplate
{
...
}
When compiling the code, the compiler will merge all partial declarations of the same class - this includes whatever interfaces the class implements etc.