aboutsummaryrefslogtreecommitdiff
path: root/ServiceStack/Host/ContentTypes.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-02-24 15:21:37 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-02-24 15:21:37 -0500
commita73eeac6869edc199c4d0915d07b6847d0c95524 (patch)
tree378241f264bbd6106ea6e958e5bf346d1f76b86e /ServiceStack/Host/ContentTypes.cs
parentc456490de43082f008dd592345e76cf75db1ad0a (diff)
parentcd6b7f3bdc5bcbc6c68131cc40b71b68ac1b73a6 (diff)
Merge branch 'master' of https://github.com/MediaBrowser/Emby
Diffstat (limited to 'ServiceStack/Host/ContentTypes.cs')
-rw-r--r--ServiceStack/Host/ContentTypes.cs63
1 files changed, 0 insertions, 63 deletions
diff --git a/ServiceStack/Host/ContentTypes.cs b/ServiceStack/Host/ContentTypes.cs
deleted file mode 100644
index f7734a36b..000000000
--- a/ServiceStack/Host/ContentTypes.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using MediaBrowser.Model.Services;
-
-namespace ServiceStack.Host
-{
- public class ContentTypes
- {
- public static ContentTypes Instance = new ContentTypes();
-
- public void SerializeToStream(IRequest req, object response, Stream responseStream)
- {
- var contentType = req.ResponseContentType;
- var serializer = GetStreamSerializer(contentType);
-
- serializer(response, responseStream);
- }
-
- public static Action<object, Stream> GetStreamSerializer(string contentType)
- {
- switch (GetRealContentType(contentType))
- {
- case "application/xml":
- case "text/xml":
- case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml
- return (o, s) => ServiceStackHost.Instance.SerializeToXml(o, s);
-
- case "application/json":
- case "text/json":
- return (o, s) => ServiceStackHost.Instance.SerializeToJson(o, s);
- }
-
- return null;
- }
-
- public Func<Type, Stream, object> GetStreamDeserializer(string contentType)
- {
- switch (GetRealContentType(contentType))
- {
- case "application/xml":
- case "text/xml":
- case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml
- return ServiceStackHost.Instance.DeserializeXml;
-
- case "application/json":
- case "text/json":
- return ServiceStackHost.Instance.DeserializeJson;
- }
-
- return null;
- }
-
- private static string GetRealContentType(string contentType)
- {
- return contentType == null
- ? null
- : contentType.Split(';')[0].ToLower().Trim();
- }
-
- }
-} \ No newline at end of file