internal protected override SmarterStringBuilder Build(SmarterStringBuilder b, bool closeScope) { if (_fDef != null) { if (b.Builder != null) { _fDef.Write(b.Builder); } else { b.Append(_fDef.ToString()); } b.HasNewLine = false; } bool lambda = CodePart.StartsWith("=>") == true; if (!lambda) { b.AppendLine().Append("{").AppendLine(); } CodePart.Build(b); _funcs.Build(b); if (closeScope && !lambda) { b.AppendLine().Append("}"); } return(b); }
private void WriteThisUsings(SmarterStringBuilder b) { foreach (var e in _usings) { b.AppendLine().Append("using ").Append(e.Key); if (e.Value.Value == null) { b.Append(";"); } else { b.Append(" = ").Append(e.Value.Value); } b.AppendLine(); } }
internal SmarterStringBuilder Build(SmarterStringBuilder b) { b.AppendLine(); foreach (var c in Parts) { if (c is BaseCodePart p) { p.Build(b); } else { b.Append((string)c); } } b.AppendLine(); return(b); }
internal protected override SmarterStringBuilder Build(SmarterStringBuilder b, bool closeScope) { if (_typeDef != null) { if (b.Builder != null) { _typeDef.Write(b.Builder); } else { b.Append(_typeDef.ToString()); } b.HasNewLine = false; } b.AppendLine().Append("{").AppendLine(); CodePart.Build(b); _funcs.Build(b); BuildTypes(b); if (closeScope) { b.AppendLine().Append("}").AppendLine(); } return(b); }
internal protected override SmarterStringBuilder Build(SmarterStringBuilder b, bool closeScope) { _beforeNamespace.Build(b); // A global using prevent any attribute definition (and [assembly::...] attributes cannot be defined // in a namespace. // We write the global usings in the TOP namespaces: they are duplicated among the top-level namespaces // but this enables to define attributes at the top of one file. if (Workspace.Global != this) { b.Append("namespace ") .Append(Name) .AppendLine() .Append("{") .AppendLine(); if (Parent == Workspace.Global) { Parent.WriteThisUsings(b); } WriteThisUsings(b); } else if (_subNamespaces.Count == 0) { // However, if there is no namespace defined, the global // usings must be written. We have no choice. WriteThisUsings(b); } CodePart.Build(b); foreach (var ns in _subNamespaces) { ns.Build(b, true); } BuildTypes(b); if (Workspace.Global != this && closeScope) { b.AppendLine().Append("}"); } return(b); }