Exemple #1
0
        protected override string ProcessTemplate(string inputFileName, string inputFileContent, ITextTemplating processor, IVsHierarchy hierarchy)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            try
            {
                TextTemplatingCallback callback = new TextTemplatingCallback(this);

                processor.BeginErrorSession();
                string templateCode = processor.PreprocessTemplate(inputFileName, inputFileContent, callback, TEMPLATE_CLASS, TEMPLATE_NAMESPACE,
                                                                   out string[] references);

                if (processor.EndErrorSession() || callback.ErrorLogged)
                {
                    return(ERROR_OUTPUT);
                }

                DetectExtensionDirective(inputFileContent);
                _encoding = callback.OutputEncoding;

                references = ProcessReferences(references, inputFileName).ToArray();

                string output = TextTemplatingHelper.ExecuteTemplate(inputFileName, templateCode, references, out TemplateError[] errors);
                GenerateErrors(errors);

                if (output == null)
                {
                    return(ERROR_OUTPUT);
                }
                else
                {
                    return(output);
                }
            }
            catch (Exception e)
            {
                GenerateError(false, $"Something went wrong processing the template '{inputFileName}': {e}");
                return(ERROR_OUTPUT);
            }
        }
 protected override string ProcessTemplate(string inputFileName, string inputFileContent, ITextTemplating processor, IVsHierarchy hierarchy)
 {
     string[] strArray;
     return(processor.PreprocessTemplate(inputFileName, inputFileContent, this, this.MakeClassName(inputFileName, hierarchy), base.FileNamespace, out strArray));
 }