Beispiel #1
0
 public override string ToString()
 {
     StringBuilder text = new StringBuilder();
     CodeWriter writer = new CodeWriter(new StringWriter(text));
     this.Output(writer);
     return text.ToString();
 }
 public override void Output(CodeWriter writer)
 {
     base.Output(writer);
     foreach (string text in Lines)
     {
         writer.WriteLine(text);
     }
 }
Beispiel #3
0
 void WriteUsings(CodeWriter writer)
 {
     foreach (string ns in Usings)
     {
         writer.WriteLine(string.Format("using {0};", ns));
     }
     writer.WriteLine();
 }
Beispiel #4
0
 public virtual void Output(CodeWriter writer)
 {
     if (Comment != null)
     {
         foreach (string line in Comment)
         {
             writer.WriteComment(line);
         }
     }
 }
 public void GenRecordCode(string directory, Record record)
 {
     string subdir = directory;
     if (record.Category != null)
     {
         subdir = Path.Combine(directory, record.Category);
         if (!Directory.Exists(subdir))
         {
             Directory.CreateDirectory(subdir);
         }
     }
     string nsName = NamespaceName + "." + Path.GetDirectoryName(record.Category);
     Namespace ns = new Namespace(nsName);
     Class cs = ExcelRecord.BuildClass(ns, record, AllRecords);
     if (cs != null)
     {
         string file = Path.Combine(subdir, record.Name + ".cs");
         CodeWriter writer = new CodeWriter(file);
         ns.AddClass(cs);
         ns.Output(writer);
         writer.Close();
     }
 }
 public override void Output(CodeWriter writer)
 {
     if (AlreadyDeclared)
     {
         if (AsignNewValue)
         {
             base.Output(writer);
             writer.WriteLine(String.Format("{0} = {1};", VariableName, Value));
         }
     }
     else
     {
         base.Output(writer);
         if (Value != null)
         {
             writer.WriteLine(String.Format("{0} {1} = {2};", TypeName, VariableName, Value));
         }
         else
         {
             writer.WriteLine(String.Format("{0} {1};", TypeName, VariableName));
         }
     }
 }
 public override void Output(CodeWriter writer)
 {
     base.Output(writer);
     writer.WriteLine(Text);
 }
 public virtual void Output(CodeWriter writer)
 {
     CodeBlock.Output(writer);
 }
Beispiel #9
0
        public override void Output(CodeWriter writer)
        {
            this.CheckVariableDeclarations();

            base.Output(writer);

            if (Style == ForamttingStyle.Line && IsAllCodeLines())
            {
                StringBuilder text = new StringBuilder();
                text.Append(Leading);
                text.Append(" {");
                foreach (CodeLine codeLine in NestedBlocks)
                {
                    text.Append(" ");
                    text.Append(codeLine.Text);
                }
                text.Append(" }");
                writer.WriteLine(text.ToString());
            }
            else
            {
                if (Leading != null)
                {
                    writer.WriteLine(Leading);
                    writer.WriteLine("{");
                    writer.Indent++;
                }
                foreach (ICodeBlock block in NestedBlocks)
                {
                    block.Output(writer);
                }
                if (Leading != null)
                {
                    writer.Indent--;
                    writer.WriteLine("}");
                }
            }
        }
Beispiel #10
0
 public void Output(string path)
 {
     CodeWriter writer = new CodeWriter(path);
     this.Output(writer);
     writer.Close();
 }
Beispiel #11
0
 public override void Output(CodeWriter writer)
 {
     WriteUsings(writer);
     base.Output(writer);
 }