XSharp.CodeDom.XSharpCodeGenerator.GenerateEntryPointMethod C# (CSharp) Method

GenerateEntryPointMethod() protected method

protected GenerateEntryPointMethod ( CodeEntryPointMethod e, CodeTypeDeclaration c ) : void
e System.CodeDom.CodeEntryPointMethod
c System.CodeDom.CodeTypeDeclaration
return void
        protected override void GenerateEntryPointMethod(CodeEntryPointMethod e, CodeTypeDeclaration c)
        {
            // we must collect this and insert it at the end of the unit
            // so replace the output field in the parent class and restore it later
            var writer = new StringWriter();
            FieldInfo field = typeof(CodeGenerator).GetField("output", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
            FieldInfo field2 = typeof(IndentedTextWriter).GetField("tabString", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
            IndentedTextWriter oldWriter = (IndentedTextWriter)field.GetValue(this);
            String tabString = (String)field2.GetValue(oldWriter);
            IndentedTextWriter newWriter = new IndentedTextWriter(writer, tabString); ;
            try
            {
                field.SetValue(this, newWriter);
                this.GenerateCommentStatements(e.Comments);

                if (e.CustomAttributes.Count > 0)
                {
                    this.GenerateAttributes(e.CustomAttributes);
                }
                base.Output.Write("FUNCTION Start() AS ");
                this.OutputType(e.ReturnType);
                base.Output.WriteLine();
                this.Indent++;
                this.GenerateStatements(e.Statements);
                this.Indent--;
                base.Output.WriteLine();
            }
            finally
            {
                entrypointCode = writer.GetStringBuilder().ToString();
                field.SetValue(this, oldWriter);
            }
        }
XSharpCodeGenerator