/// <inheritdoc /> public HttpContent ConvertToHttpContent(Type typeToConvert, object content) { var xDocument = content as XDocument; if (xDocument == null) { return null; } using (var stringWriter = new StringWriter()) using (var xmlTextWriter = new XmlTextWriter(stringWriter)) { xDocument.WriteTo(xmlTextWriter); var httpContent = new StringContent(stringWriter.ToString()); httpContent.SetContentType($"{MediaTypes.Xml.EnumValueOf()}; charset={stringWriter.Encoding.EncodingName}"); return httpContent; } }
/// <inheritdoc /> public HttpContent ConvertToHttpContent(Type typeToConvert, object content) { var feed = content as SyndicationFeed; if (feed == null) { return null; } using (var stringWriter = new StringWriter()) using (var xmlTextWriter = new XmlTextWriter(stringWriter)) { var rss2Formatter = feed.GetRss20Formatter(); rss2Formatter.WriteTo(xmlTextWriter); var httpContent = new StringContent(stringWriter.ToString()); httpContent.SetContentType($"{MediaTypes.Rss.EnumValueOf()}; charset={stringWriter.Encoding.EncodingName}"); return httpContent; } }