/// <summary> /// An XML representation of the Request /// </summary> /// <returns>an XML string</returns> public string ToXml() { XmlDocument dom = new XmlDocument(); XmlElement root = (XmlElement)dom.AppendChild(dom.CreateElement("request")); root.SetAttribute("id", Id.ToString()); root.AppendChild(dom.CreateElement("servicekey")).InnerText = ServiceKey; root.AppendChild(dom.CreateElement("methodkey")).InnerText = MethodKey; root.AppendChild(dom.CreateElement("formatkey")).InnerText = FormatKey; XmlElement application = (XmlElement)root.AppendChild(dom.CreateElement("application")); application.AppendChild(dom.CreateElement("id")).InnerText = APIKey.Application.Id.ToString(); application.AppendChild(dom.CreateElement("name")).InnerText = APIKey.Application.Name; application.AppendChild(dom.CreateElement("apikey")).InnerText = APIKey.Key; root.AppendChild(dom.CreateElement("isservicetoservice")).InnerText = IsServiceToService.ToString(); root.AppendChild(dom.CreateElement("clientipaddress")).InnerText = Requestor.ClientIPAddress; root.AppendChild(dom.CreateElement("hostipaddress")).InnerText = Requestor.HostIPAddress; root.AppendChild(dom.CreateElement("ishostinternal")).InnerText = Requestor.IsHostInternal.ToString(); XmlDocumentFragment xFragment = dom.CreateDocumentFragment(); xFragment.InnerXml = ParameterSet.ToXml().OuterXml; root.AppendChild(xFragment); return(dom.OuterXml); }
/// <summary> /// A string representation of the Request /// </summary> /// <returns>a string representation of the request</returns> public override string ToString() { string parameters = string.Empty; foreach (KeyValuePair <string, string> kvp in ParameterSet.Parameters) { parameters += string.Format(" {0}: {1}\n", kvp.Key, kvp.Value); } string s = Settings.GetString("ToStringFormatRequest", new Dictionary <string, string>() { { "Id", Id.ToString() }, { "ServiceKey", ServiceKey }, { "MethodKey", MethodKey }, { "FormatKey", FormatKey }, { "ApplicationId", APIKey.Application.Id.ToString() }, { "ApplicationName", APIKey.Application.Name }, { "ApiKey", APIKey.Key }, { "IsServiceToService", IsServiceToService.ToString() }, { "ClientIpAddress", Requestor.ClientIPAddress }, { "HostIpAddress", Requestor.HostIPAddress }, { "IsHostInternal", Requestor.IsHostInternal.ToString() }, { "Parameters", parameters } }); return(s); }