aboutsummaryrefslogtreecommitdiff
path: root/ServiceStack/ServiceStackHost.cs
blob: 09fe9a242183f36434d001bc4ee728b4e706753f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) Service Stack LLC. All Rights Reserved.
// License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt


using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using MediaBrowser.Model.Services;

namespace ServiceStack
{
    public abstract class ServiceStackHost : IDisposable
    {
        public static ServiceStackHost Instance { get; protected set; }

        protected ServiceStackHost()
        {
            GlobalResponseFilters = new List<Action<IRequest, IResponse, object>>();
        }

        public abstract object CreateInstance(Type type);

        public List<Action<IRequest, IResponse, object>> GlobalResponseFilters { get; set; }

        public abstract RouteAttribute[] GetRouteAttributes(Type requestType);

        public abstract Func<string, object> GetParseFn(Type propertyType);

        public abstract void SerializeToJson(object o, Stream stream);
        public abstract void SerializeToXml(object o, Stream stream);
        public abstract object DeserializeXml(Type type, Stream stream);
        public abstract object DeserializeJson(Type type, Stream stream);

        public virtual void Dispose()
        {
            //JsConfig.Reset(); //Clears Runtime Attributes

            Instance = null;
        }
    }
}