/// <summary> /// Writes a header line with the items provided in the List /// </summary> /// <param name="Headers"></param> public void WriteHeaderLine(List <string> Headers) { if (Transpose) { if (Formatted != null) { ResponseBody.Append(Formatted.ToString()); } Formatted = new FormattedOutput(Headers); Formatted.Transpose = true; } else { ResponseBody.AppendFormat("\nH\t{0}", String.Join("\t", Headers)); } }
/// <summary> /// Writes a Header line with the specified parameters /// </summary> /// <param name="Params"></param> public void WriteHeaderLine(params object[] Params) { if (Transpose) { if (Formatted != null) { ResponseBody.Append(Formatted.ToString()); } Formatted = new FormattedOutput(Params); Formatted.Transpose = true; } else { ResponseBody.AppendFormat("\nH\t{0}", String.Join("\t", Params)); } }
/// <summary> /// Adds HeaderData to the current output /// </summary> /// <param name="Data"></param> public void WriteHeaderDataPair(Dictionary <string, object> Data) { if (Transpose) { if (Formatted != null) { ResponseBody.Append(Formatted.ToString()); } List <string> Params = new List <string>(Data.Count); foreach (KeyValuePair <string, object> Item in Data) { Params.Add(Item.Key); } Formatted = new FormattedOutput(Params); Formatted.Transpose = true; Params = new List <string>(Data.Count); foreach (KeyValuePair <string, object> Item in Data) { Params.Add(Item.Value.ToString()); } Formatted.AddRow(Params); } else { // Add Keys ResponseBody.Append("\nH"); foreach (KeyValuePair <string, object> Item in Data) { ResponseBody.Append("\t" + Item.Key); } // Add Data ResponseBody.Append("\nD"); foreach (KeyValuePair <string, object> Item in Data) { ResponseBody.Append("\t" + Item.Value); } } }
/// <summary> /// Sends all output to the browser /// </summary> public new void Send() { // Make sure our client didnt send a response already if (base.ResponseSent) { return; } // Whats left of the transposed data if (StatusCode == 200) { if (Transpose && Formatted != null) { ResponseBody.Append(Formatted.ToString()); } WriteResponseEnd(); Response.ContentType = "text/plain"; } base.Send(); }
/// <summary> /// Adds HeaderData to the current output /// </summary> /// <param name="Data"></param> public void AddData(FormattedOutput Data) { Data.Transpose = Transpose; ResponseBody.Append(Data.ToString().Trim()); }