/// <summary> /// Overloaded ToString function for formatting the output on the console. /// </summary> /// <param name="healthStateCount"> Object of type HealthStateCount </param> /// <returns> /// Returns formatted string. /// </returns> public static string ToString(HealthStateCount healthStateCount) { var strBuilder = new StringBuilder(); strBuilder.Append(string.Format(CultureInfo.CurrentCulture, "{0, -21} : {1}", "OkCount", healthStateCount.OkCount)); strBuilder.Append(Environment.NewLine); strBuilder.Append(string.Format(CultureInfo.CurrentCulture, "{0, -21} : {1}", "WarningCount", healthStateCount.WarningCount)); strBuilder.Append(Environment.NewLine); strBuilder.Append(string.Format(CultureInfo.CurrentCulture, "{0, -21} : {1}", "ErrorCount", healthStateCount.ErrorCount)); strBuilder.Append(Environment.NewLine); return(strBuilder.ToString()); }
/// <summary> /// Serializes the object to JSON. /// </summary> /// <param name="writer">The <see cref="T: Newtonsoft.Json.JsonWriter" /> to write to.</param> /// <param name="obj">The object to serialize to JSON.</param> internal static void Serialize(JsonWriter writer, HealthStateCount obj) { // Required properties are always serialized, optional properties are serialized when not null. writer.WriteStartObject(); if (obj.OkCount != null) { writer.WriteProperty(obj.OkCount, "OkCount", JsonWriterExtensions.WriteLongValue); } if (obj.WarningCount != null) { writer.WriteProperty(obj.WarningCount, "WarningCount", JsonWriterExtensions.WriteLongValue); } if (obj.ErrorCount != null) { writer.WriteProperty(obj.ErrorCount, "ErrorCount", JsonWriterExtensions.WriteLongValue); } writer.WriteEndObject(); }