src/T4Toolbox.DirectiveProcessors/TransformationContextProcessor.cs
/// <summary>
/// Generates code in the class area of the transformation class created by the T4 engine.
/// </summary>
/// <param name="arguments">The arguments for the directive.</param>
Generates code in the class area of the transformation class created by the T4 engine.
Generates code in the class area of the transformation class created by the T4 engine .
protected override void Process(IDictionary<string, string> arguments)
        {
            if (this.directiveProcessed)
            {
                this.Warning("Multiple <#@ include file=\"T4Toolbox.tt\" #> directives were found in the template.");
                return;
            }
            this.References.Add(typeof(TransformationContext).Assembly.Location);
            var initialize = new CodeExpressionStatement(
                new CodeMethodInvokeExpression(
                    new CodeTypeReferenceExpression(typeof(TransformationContext).FullName),
                    "Initialize",
                    new CodeThisReferenceExpression(),
                    new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "GenerationEnvironment")));
            this.LanguageProvider.GenerateCodeFromStatement(initialize, this.PreInitializationCode, null);
            var cleanup = new CodeExpressionStatement(
                new CodeMethodInvokeExpression(
                    new CodeTypeReferenceExpression(typeof(TransformationContext).FullName),
                    "Cleanup"));
            this.LanguageProvider.GenerateCodeFromStatement(cleanup, this.DisposeCode, null);
            this.directiveProcessed = true;
        }
protected override void Process ( IDictionary < string , string > arguments ) { if ( this . directiveProcessed ) { this . Warning ( " \" \" " ) ; return ; } this . References . Add ( typeof ( TransformationContext ) . Assembly . Location ) ; var initialize = new CodeExpressionStatement ( new CodeMethodInvokeExpression ( new CodeTypeReferenceExpression ( typeof ( TransformationContext ) . FullName ) , " " , new CodeThisReferenceExpression ( ) , new CodePropertyReferenceExpression ( new CodeThisReferenceExpression ( ) , " " ) ) ) ; this . LanguageProvider . GenerateCodeFromStatement ( initialize , this . PreInitializationCode , null ) ; var cleanup = new CodeExpressionStatement ( new CodeMethodInvokeExpression ( new CodeTypeReferenceExpression ( typeof ( TransformationContext ) . FullName ) , " " ) ) ; this . LanguageProvider . GenerateCodeFromStatement ( cleanup , this . DisposeCode , null ) ; this . directiveProcessed = true ; }
Generates code in the class area of the transformation class created by the T4 engine.
Generates code in the class area of the transformation class created by the T4 engine .
// Don't generate the same code more then once if T4Toolbox.tt happens to be included multiple times // Add the following method call to the Initialize method of the generated text template. // T4Toolbox.TransformationContext.Initialize(this, this.GenerationEnvironment); // Add the following method call to the Dispose(bool) method of the generated text template. // T4Toolbox.TransformationContext.Cleanup();
arguments
IDictionary<string, string>
The arguments for the directive.
The arguments for the directive .