public string PrintToJSON(int tabCount, bool useComma) { string printout = ""; string comma = ""; if (useComma) { comma = ","; } printout += new string('\t', tabCount) + "{\r\n"; printout += MyReportWriter.PrintJsonElement("ConditionId", id, tabCount + 1, true); printout += MyReportWriter.PrintJsonElement("ConditionOperation", operation.ToString(), tabCount + 1, true); printout += MyReportWriter.PrintJsonNumElement("ConditionParam1", param1, tabCount + 1, true); if (useTwoParams) { printout += MyReportWriter.PrintJsonNumElement("ConditionParam2", param2, tabCount + 1, true); } printout += MyReportWriter.PrintJsonNumElement("ConditionValue", outcome, tabCount + 1, true); printout += MyReportWriter.PrintJsonElement("ConditionStatus", status.ToString(), tabCount + 1, false); printout += new string('\t', tabCount) + "}" + comma + "\r\n"; return(printout); }
public string PrintToJSON(int tabCount, bool useComma) { string printout = ""; string comma = ""; if (useComma) { comma = ","; } printout += new string('\t', tabCount) + "{\r\n"; printout += MyReportWriter.PrintJsonNumElement("TestIdx", idx, tabCount + 1, true); printout += MyReportWriter.PrintJsonElement("TestType", type.ToString(), tabCount + 1, true); printout += MyReportWriter.PrintJsonElement("TestDescription", description, tabCount + 1, true); printout += new string('\t', tabCount + 1) + "\"Conditions\": [\r\n"; for (int i = 0; i < conditions.Count; i++) { if (i < (conditions.Count - 1)) { printout += conditions[i].PrintToJSON(tabCount + 2, true); } else { printout += conditions[i].PrintToJSON(tabCount + 2, false); } } printout += new string('\t', tabCount + 1) + "],\r\n"; if (comments != "") { printout += MyReportWriter.PrintJsonElement("ResultStatus", status.ToString(), tabCount + 1, true); printout += MyReportWriter.PrintJsonElement("Comments", comments, tabCount + 1, false); } else { printout += MyReportWriter.PrintJsonElement("ResultStatus", status.ToString(), tabCount + 1, false); } printout += new string('\t', tabCount) + "}" + comma + "\r\n"; return(printout); }