Exemple #1
0
        /// <summary>
        /// Validates and runs the generator.
        /// </summary>
        public void Run()
        {
            this.Errors.Clear();

            try
            {
                this.Validate();
                if (!this.Errors.HasErrors)
                {
                    this.RunCore();
                }
            }
            catch (TransformationException e)
            {
                this.Error(e.Message);
            }

            TransformationContext.ReportErrors(this.Errors);
        }
Exemple #2
0
        public static void OnTransformationEnded(TextTransformation transformation)
        {
            try
            {
                if (transformation == null)
                {
                    throw new ArgumentNullException("transformation");
                }

                if (TransformationContext.transformation != null && !TransformationContext.Errors.HasErrors)
                {
                    // Update the files in the default AppDomain to avoid remoting errors on Database projects
                    BindingFlags invokeInternalStaticMethod = BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.NonPublic;
                    AppDomain    defaultDomain = (AppDomain)typeof(AppDomain).InvokeMember("GetDefaultDomain", invokeInternalStaticMethod, null, null, null, CultureInfo.InvariantCulture);
                    defaultDomain.DoCallBack(TransformationContext.outputManager.UpdateFiles);
                }

                TransformationContext.transformation = null;
                TransformationContext.outputManager  = null;
                TransformationContext.project        = null;
                TransformationContext.projectItem    = null;
                TransformationContext.dte            = null;

                if (TransformationContext.TransformationEnded != null)
                {
                    TransformationContext.TransformationEnded(null, EventArgs.Empty);
                }
            }
            catch (TransformationException e)
            {
                // Display expected errors in the Error List window without the call stack
                CompilerErrorCollection errors = new CompilerErrorCollection();
                CompilerError           error  = new CompilerError();
                error.ErrorText = e.Message;
                error.FileName  = Host.TemplateFile;
                errors.Add(error);
                TransformationContext.Host.LogErrors(errors);
            }
            finally
            {
                DestroyTraceListener();
            }
        }
Exemple #3
0
 /// <summary>
 /// This method is a part of T4 Toolbox infrastructure. Don't call it in your code.
 /// </summary>
 /// <param name="content">
 /// Generated content.
 /// </param>
 /// <param name="output">
 /// An <see cref="OutputInfo"/> object that specifies how the content must be saved.
 /// </param>
 /// <param name="errors">
 /// A collection of <see cref="CompilerError"/> objects that represent errors and warnings
 /// that occurred while generating this content.
 /// </param>
 internal static void Render(string content, OutputInfo output, CompilerErrorCollection errors)
 {
     TransformationContext.ReportErrors(errors);
     TransformationContext.outputManager.Append(output, content, Host, Transformation);
 }