Esempio n. 1
0
        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"));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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"
            });
        }
Esempio n. 4
0
        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;
            });
        }
Esempio n. 5
0
        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"
                };
            });
        }