Beispiel #1
0
 private void FillRuntimeError(TemplateRuntimeException ex)
 {
     if (this.template.parser.TemplateFile != null)
     {
         ex.SourceFileName = this.template.parser.TemplateFile;
     }
 }
Beispiel #2
0
 private void DisplayError(Exception ex)
 {
     if (ex is TemplateRuntimeException)
     {
         TemplateRuntimeException tex = (TemplateRuntimeException)ex;
         DisplayError(ex.Message, tex.Line, tex.Col);
     }
     else
     {
         DisplayError(ex.Message, 0, 0);
     }
 }
Beispiel #3
0
            public void Render(IDictionary <string, TextWriter> writers)
            {
                if (writers == null)
                {
                    throw new ArgumentNullException("writers");
                }

                object[] parameters;

                if (this.context == null)
                {
                    parameters = new object[1];
                }
                else
                {
                    parameters = new object[this.context.Length + 1];
                }

                parameters[0] = writers;

                for (int i = 1; i < parameters.Length; i++)
                {
                    parameters[i] = this.context[i - 1];
                }

                try
                {
                    this.template.generatorType.InvokeMember(
                        "Generate",
                        BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance,
                        null,
                        this.GeneratorInstance,
                        parameters);
                }
                catch (TargetInvocationException ex)
                {
                    TemplateRuntimeException e = new TemplateRuntimeException(
                        ex.InnerException.Message,
                        ex.InnerException);
                    this.FillRuntimeError(e);
                    throw e;
                }
                catch (Exception ex)
                {
                    TemplateRuntimeException e = new TemplateRuntimeException(
                        ex.Message,
                        ex);
                    this.FillRuntimeError(e);
                    throw e;
                }
            }
Beispiel #4
0
 private void FillRuntimeError(TemplateRuntimeException ex)
 {
     if (this.template.parser.TemplateFile != null)
     {
         ex.SourceFileName = this.template.parser.TemplateFile;
     }
 }
Beispiel #5
0
            public void Render(IDictionary<string, TextWriter> writers)
            {
                if (writers == null)
                {
                    throw new ArgumentNullException("writers");
                }

                object[] parameters;

                if (this.context == null)
                {
                    parameters = new object[1];
                }
                else
                {
                    parameters = new object[this.context.Length + 1];
                }

                parameters[0] = writers;

                for (int i = 1; i < parameters.Length; i++)
                {
                    parameters[i] = this.context[i - 1];
                }

                try
                {
                    this.template.generatorType.InvokeMember(
                        "Generate",
                        BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance,
                        null,
                        this.GeneratorInstance,
                        parameters);
                }
                catch (TargetInvocationException ex)
                {
                    TemplateRuntimeException e = new TemplateRuntimeException(
                        ex.InnerException.Message,
                        ex.InnerException);
                    this.FillRuntimeError(e);
                    throw e;
                }
                catch (Exception ex)
                {
                    TemplateRuntimeException e = new TemplateRuntimeException(
                        ex.Message,
                        ex);
                    this.FillRuntimeError(e);
                    throw e;
                }
            }