예제 #1
0
파일: AtTemplate.cs 프로젝트: anthrax3/dcg
 private void FillRuntimeError(TemplateRuntimeException ex)
 {
     if (this.template.parser.TemplateFile != null)
     {
         ex.SourceFileName = this.template.parser.TemplateFile;
     }
 }
예제 #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);
     }
 }
예제 #3
0
파일: AtTemplate.cs 프로젝트: anthrax3/dcg
            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;
                }
            }
예제 #4
0
파일: AtTemplate.cs 프로젝트: sethyuan/dcg
 private void FillRuntimeError(TemplateRuntimeException ex)
 {
     if (this.template.parser.TemplateFile != null)
     {
         ex.SourceFileName = this.template.parser.TemplateFile;
     }
 }
예제 #5
0
파일: AtTemplate.cs 프로젝트: sethyuan/dcg
            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;
                }
            }