public static string GetGoogleVisualizationResponse(GoogleVisualizationResponse googleVisualizationResponse) { if (googleVisualizationResponse == null) throw new ArgumentException("The googleVisualizationResponse is required"); if (googleVisualizationResponse.GoogleVisualizationRequest == null) // failsafe throw new ArgumentException("The GoogleVisualizationRequest property is required in the googleVisualizationResponse instance"); StringBuilder result = new StringBuilder(); result.Append(googleVisualizationResponse.GoogleVisualizationRequest.ResponseHandler); result.Append("({"); result.Append(string.Format("version:'{0}',", googleVisualizationResponse.Version.ToString())); result.Append(string.Format("reqId:'{0}',", googleVisualizationResponse.RequestId.ToString())); result.Append(string.Format("status:'{0}'", Enum.GetName(typeof(GoogleVisualizationResponseStatus), googleVisualizationResponse.Status).ToLower())); if (googleVisualizationResponse.WarningInfo != null) { result.Append(",warnings:[{"); foreach (WarningInfo warningInfo in googleVisualizationResponse.WarningInfo) { result.Append(string.Format("reason:'{0}'", warningInfo.Reason)); if (string.IsNullOrWhiteSpace(warningInfo.ShortMessage) == false) result.Append(string.Format(",message:'{0}'", warningInfo.ShortMessage)); if (string.IsNullOrWhiteSpace(warningInfo.DetailedMessage) == false) result.Append(string.Format(",detailed_message:'{0}'", warningInfo.DetailedMessage)); } result.Append("}]"); } if (googleVisualizationResponse.ErrorInfo != null) { result.Append(",errors:[{"); foreach (ErrorInfo errorInfo in googleVisualizationResponse.ErrorInfo) { result.Append(string.Format("reason:'{0}'", errorInfo.Reason)); if (string.IsNullOrWhiteSpace(errorInfo.ShortMessage) == false) result.Append(string.Format(",message:'{0}'", errorInfo.ShortMessage)); if (string.IsNullOrWhiteSpace(errorInfo.DetailedMessage) == false) result.Append(string.Format(",detailed_message:'{0}'", errorInfo.DetailedMessage)); } result.Append("}]"); } if (string.IsNullOrWhiteSpace(googleVisualizationResponse.HashSig) == false) result.Append(string.Format(",sig:'{0}',", googleVisualizationResponse.HashSig)); if (googleVisualizationResponse.GoogleVisualizationDataTable != null) { result.Append(string.Format(",table:{0}", JsonSerializeGoogleVisualizationDataTable(googleVisualizationResponse.GoogleVisualizationDataTable))); } result.Append("});"); return result.ToString(); }
public GoogleVisualizationResult(GoogleVisualizationResponse googleVisualizationResponse) { GoogleVisualizationResponse = googleVisualizationResponse; }