public static Response AsXml(this IResponseFormatter formatter, IXMLEntity entity) { var doc = new XmlDocument(); var firstChild = entity.Serialize(doc); doc.AppendChild(firstChild); return(FormatterExtensions.AsText(formatter, doc.OuterXml).WithContentType("text/xml")); }
public static HttpResponseMessage Xml(HttpStatusCode code, IXMLEntity xml) { var doc = new XmlDocument(); var firstChild = xml.Serialize(doc); doc.AppendChild(firstChild); var response = new HttpResponseMessage(code); response.Content = new StringContent(doc.OuterXml, Encoding.UTF8, "text/xml"); return(response); }
public static IActionResult Xml(HttpStatusCode code, IXMLEntity xml) { var doc = new XmlDocument(); var firstChild = xml.Serialize(doc); doc.AppendChild(firstChild); return(new ContentResult { StatusCode = (int)code, Content = doc.OuterXml, ContentType = "text/xml" }); }
public static Func <HttpResponseMessage> XmlFuture(HttpStatusCode code, IXMLEntity xml) { var doc = new XmlDocument(); var firstChild = xml.Serialize(doc); doc.AppendChild(firstChild); var serialized = doc.OuterXml; return(() => { var response = new HttpResponseMessage(code); response.Content = new StringContent(serialized, Encoding.UTF8, "text/xml"); return response; }); }
public static Func <IActionResult> XmlFuture(HttpStatusCode code, IXMLEntity xml) { var doc = new XmlDocument(); var firstChild = xml.Serialize(doc); doc.AppendChild(firstChild); var serialized = doc.OuterXml; return(() => { return new ContentResult { StatusCode = (int)code, Content = serialized, ContentType = "text/xml" }; }); }