src/T4Toolbox.VisualStudio/TemplatedFileGenerator.cs
/// <summary>
/// Extracts template name from the input file metadata, resolves its full name using the built-in T4 logic
/// for loading include files, loads the template content and passes it to the base class to transform.
/// </summary>
Extracts template name from the input file metadata, resolves its full name using the built-in T4 logic
for loading include files, loads the template content and passes it to the base class to transform.
Extracts template name from the input file metadata resolves its full name using the built - in T4 logic for loading include files loads the template content and passes it to the base class to transform .
protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
        {
            this.TextTemplating.BeginErrorSession();
            try
            {
                var sessionHost = (ITextTemplatingSessionHost)this.TextTemplating;
                sessionHost.Session[TransformationContext.InputFileNameKey] = inputFileName;
                sessionHost.Session[TransformationContext.InputFileContentKey] = inputFileContent;
                if (this.ResolveTemplate(ref inputFileName, ref inputFileContent))
                {
                    return base.GenerateCode(inputFileName, inputFileContent);
                }
                return Encoding.Default.GetBytes("ErrorGeneratingOutput");
            }
            finally
            {
                this.TextTemplating.EndErrorSession();
            }
        }
protected override byte [ ] GenerateCode ( string inputFileName , string inputFileContent ) { this . TextTemplating . BeginErrorSession ( ) ; try { var sessionHost = ( ITextTemplatingSessionHost ) this . TextTemplating ; sessionHost . Session [ TransformationContext . InputFileNameKey ] = inputFileName ; sessionHost . Session [ TransformationContext . InputFileContentKey ] = inputFileContent ; if ( this . ResolveTemplate ( ref inputFileName , ref inputFileContent ) ) { return base . GenerateCode ( inputFileName , inputFileContent ) ; } return Encoding . Default . GetBytes ( " " ) ; } finally { this . TextTemplating . EndErrorSession ( ) ; } }
Extracts template name from the input file metadata, resolves its full name using the built-in T4 logic
for loading include files, loads the template content and passes it to the base class to transform.
Extracts template name from the input file metadata resolves its full name using the built - in T4 logic for loading include files loads the template content and passes it to the base class to transform .
// Begin a new error session to make sure errors we log here are not removed when the base method is called. // Pass the name and content of the input file to the transformation // Resolve template file name based on input metadata // Perform default transformation of the template
inputFileName
string
inputFileContent
string