private string RenderScoreToJson(DefinitionObject score, int idLanguage) { StringBuilder result = new StringBuilder(); if (score.IsScoreGroup()) { object _enabled = score.GetValue("Enabled"); result.Append("{"); result.Append(string.Format( " \"Type\": \"ScoreGroup\", \"Id\": \"{0}\", \"Name\": \"{1}\", \"Order\": \"{2}\", \"Path\": \"{3}\", \"Source\": \"{4}\", \"Value\": \"{5}\", \"Enabled\": {6}, \"Color\":\"{7}\", \"Scores\": [", score.GetValue("Id"), HttpUtility.HtmlEncode(score.GetLabel(idLanguage)), score.GetValue("Order"), score.Path.Replace("\"", "\\\""), score.Source, score.GetValue("Value"), _enabled != null ? _enabled.ToString().ToLower() : true.ToString().ToLower(), score.GetValue("Color") )); /*foreach (XmlNode xmlNodeScore in xmlNode.ChildNodes) * { * result.Append(RenderScoreToJson(xmlNodeScore, idLanguage)); * result.Append(","); * }*/ DefinitionObject[] childScores = score.GetChilds(); foreach (DefinitionObject childScore in childScores) { result.Append(RenderScoreToJson(childScore, idLanguage)); result.Append(","); } if (childScores.Length > 0) { result = result.Remove(result.Length - 1, 1); } result.Append("] }"); } else { object _enabled = score.GetValue("Enabled"); result.Append("{"); result.Append(string.Format( " \"Type\": \"{0}\", \"Id\": \"{1}\", \"Label\": \"{2}\", \"Order\": \"{3}\", \"Path\": \"{4}\", \"Enabled\": {5}, \"Source\": \"{6}\", \"Name\": \"{7}\", \"Value\": \"{8}\" ", score.TypeName, score.GetValue("Id"), HttpUtility.HtmlEncode(score.GetLabel(idLanguage)), score.GetValue("Order"), score.Path.Replace("\"", "\\\""), _enabled != null ? _enabled.ToString().ToLower() : true.ToString().ToLower(), score.Source, HttpUtility.HtmlEncode(score.GetValue("Name")), score.GetValue("Value") )); result.Append("}"); } return(result.ToString()); }