private void BuildBaseType(StringBuilder stringBuilder, TemplateSettings settings) { //Add the base class if (!string.IsNullOrEmpty(@base)) { stringBuilder.Append(" : "); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.Append(@base); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); } //Add the interfaces for (int i = 0; i < interfaces.Count; ++i) { //Append the delimiter if (i == 0) { stringBuilder.Append(string.IsNullOrEmpty(@base) ? " : " : ", "); } else { stringBuilder.Append(", "); } //Add the interface TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.Append(interfaces[i].id); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); } }
public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings settings) { string modifiedID = GetModifiedID(settings); if (string.IsNullOrEmpty(modifiedID)) { base.ToCSharp(stringBuilder, indentationLevel, settings); } else { //Start stringBuilder.AppendIndentations(indentationLevel); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); stringBuilder.Append("namespace "); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); stringBuilder.Append(modifiedID); stringBuilder.Append("\n"); stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("{\n"); //Body base.ToCSharp(stringBuilder, indentationLevel + 1, settings); //End stringBuilder.Append("\n"); stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("}"); } }
/// Converts the XML object into C# and adds it to the string builder public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings settings) { stringBuilder.AppendIndentations(indentationLevel); //Accessibility TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); stringBuilder.Append(accessibility); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); //Static and Virtuality stringBuilder.AppendSpace(); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); stringBuilder.AppendIf("static ", isStatic); stringBuilder.AppendIf(virtuality.ToString() + " ", virtuality != Virtuality.none); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); //Type TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.Append(type ?? "?"); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); //Name stringBuilder.AppendSpace(); stringBuilder.Append(id); //Children if (children.Count > 0) { stringBuilder.Append("\n"); stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("{\n"); base.ToCSharp(stringBuilder, indentationLevel + 1, settings); stringBuilder.Append("\n"); stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("}"); } else { //Default if (!string.IsNullOrEmpty(defaultValue)) { stringBuilder.Append(" = "); if (type.Equals("string", System.StringComparison.InvariantCultureIgnoreCase)) { stringBuilder.Append("\""); stringBuilder.Append(defaultValue); stringBuilder.Append("\""); } else { stringBuilder.Append(defaultValue); } } stringBuilder.Append(';'); } }
public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings settings) { TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.USING_NAMESPACE_COLOR); { stringBuilder.Append("using "); stringBuilder.Append(id); stringBuilder.Append(";"); } TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.USING_NAMESPACE_COLOR); }
/// Converts the XML object into C# and adds it to the string builder public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings templateSettings) { stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("["); //Type TemplateBuilder.BeginColorBlock(stringBuilder, templateSettings, TemplateSettings.TYPE_COLOR); stringBuilder.Append(id); TemplateBuilder.EndColorBlock(stringBuilder, templateSettings, TemplateSettings.TYPE_COLOR); //Arguments if (!string.IsNullOrEmpty(innerText)) { stringBuilder.Append($"({innerText})"); } stringBuilder.Append("]"); }
/// Converts the XML object into C# and adds it to the string builder public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings templateSettings) { if (children.Count > 0) { //Accessibility stringBuilder.AppendIndentations(indentationLevel); TemplateBuilder.BeginColorBlock(stringBuilder, templateSettings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); stringBuilder.AppendIf(accessibility + " ", !string.IsNullOrEmpty(accessibility)); TemplateBuilder.EndColorBlock(stringBuilder, templateSettings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); //Get or Set TemplateBuilder.BeginColorBlock(stringBuilder, templateSettings, TemplateSettings.SYSTEM_KEYWORD_COLOR); stringBuilder.Append(keyword); TemplateBuilder.EndColorBlock(stringBuilder, templateSettings, TemplateSettings.SYSTEM_KEYWORD_COLOR); //Body BodyToCSharp(stringBuilder, indentationLevel, templateSettings); } }
/// Converts the XML object into C# and adds it to the string builder public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings settings) { //Signature stringBuilder.AppendIndentations(indentationLevel); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); stringBuilder.Append(accessibility); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); stringBuilder.AppendSpace(); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); stringBuilder.Append(kind); stringBuilder.AppendSpace(); stringBuilder.AppendIf("static ", isStatic); stringBuilder.AppendIf("partial", isPartial); stringBuilder.AppendIf("abstract ", isAbstract); stringBuilder.AppendIf("sealed ", isSealed); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.Append(id); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); BuildBaseType(stringBuilder, settings); stringBuilder.Append("\n"); //Body start stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("{\n"); //Body XmlTemplate.ChildrenToCSharp(stringBuilder, indentationLevel + 1, settings, children); //Body end stringBuilder.Append("\n"); stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("}"); }
/// Converts the XML object into C# and adds it to the string builder public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings settings) { //Signature stringBuilder.AppendIndentations(indentationLevel); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); stringBuilder.Append(accessibility); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.ACCESSIBILITY_KEYWORD_COLOR); stringBuilder.AppendSpace(); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); stringBuilder.AppendIf("static ", isStatic); stringBuilder.AppendIf("sealed ", isSealed); if (virtuality != Virtuality.none) { stringBuilder.Append(virtuality.ToString().Replace("@", null)); stringBuilder.AppendSpace(); } TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.SYSTEM_KEYWORD_COLOR); TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.Append(returnType ?? "void"); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.AppendSpace(); stringBuilder.Append(id); //Arguments stringBuilder.Append("("); for (int i = 0; i < arguments.Count; ++i) { XmlArgument argument = arguments[i]; TemplateBuilder.BeginColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.Append(argument.type ?? "?"); TemplateBuilder.EndColorBlock(stringBuilder, settings, TemplateSettings.TYPE_COLOR); stringBuilder.AppendSpace(); stringBuilder.Append(argument.id ?? "?"); if (i < arguments.Count - 1) { stringBuilder.Append(", "); } } stringBuilder.Append(")"); //Body if (virtuality == Virtuality.@abstract) { stringBuilder.Append(";\n"); } else { stringBuilder.Append("\n"); stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("{\n"); base.ToCSharp(stringBuilder, indentationLevel + 1, settings); stringBuilder.Append("\n"); stringBuilder.AppendIndentations(indentationLevel); stringBuilder.Append("}"); } }
public override void ToCSharp(StringBuilder stringBuilder, int indentationLevel, TemplateSettings settings) { TemplateBuilder.BeginColorBlock(stringBuilder, settings, textColor); stringBuilder.AppendWithIndentation(body, indentationLevel); TemplateBuilder.EndColorBlock(stringBuilder, settings, textColor); }