forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicAppHost.cs
More file actions
83 lines (63 loc) · 2.76 KB
/
BasicAppHost.cs
File metadata and controls
83 lines (63 loc) · 2.76 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Funq;
using ServiceStack.Html;
using ServiceStack.VirtualPath;
using ServiceStack.ServiceHost;
using ServiceStack.WebHost.Endpoints;
namespace ServiceStack.ServiceInterface.Testing
{
public class BasicAppHost : IAppHost
{
public BasicAppHost()
{
this.Container = new Container();
this.PreRequestFilters = new List<Action<IHttpRequest, IHttpResponse>>();
this.RequestFilters = new List<Action<IHttpRequest, IHttpResponse, object>>();
this.ResponseFilters = new List<Action<IHttpRequest, IHttpResponse, object>>();
this.ViewEngines = new List<IViewEngine>();
this.CatchAllHandlers = new List<HttpHandlerResolverDelegate>();
VirtualPathProvider = new FileSystemVirtualPathProvider(this, "~".MapServerPath());
}
public void RegisterAs<T, TAs>() where T : TAs
{
this.Container.RegisterAs<T, TAs>();
}
public virtual void Release(object instance) { }
public void OnEndRequest() {}
public void Register<T>(T instance)
{
this.Container.Register(instance);
}
public T TryResolve<T>()
{
return this.Container.TryResolve<T>();
}
public Container Container { get; set; }
public IContentTypeFilter ContentTypeFilters { get; set; }
public List<Action<IHttpRequest, IHttpResponse>> PreRequestFilters { get; set; }
public List<Action<IHttpRequest, IHttpResponse, object>> RequestFilters { get; set; }
public List<Action<IHttpRequest, IHttpResponse, object>> ResponseFilters { get; set; }
public List<IViewEngine> ViewEngines { get; set; }
public Action<IHttpRequest, IHttpResponse, string, Exception> ExceptionHandler { get; set; }
public List<HttpHandlerResolverDelegate> CatchAllHandlers { get; set; }
public Dictionary<Type, Func<IHttpRequest, object>> RequestBinders
{
get { throw new NotImplementedException(); }
}
public EndpointHostConfig Config { get; set; }
public void RegisterService(Type serviceType, params string[] atRestPaths)
{
if (Config == null)
Config = new EndpointHostConfig("BasicAppHost", new ServiceManager(Assembly.GetExecutingAssembly()));
Config.ServiceManager.RegisterService(serviceType);
}
public void LoadPlugin(params IPlugin[] plugins)
{
plugins.ToList().ForEach(x => x.Register(this));
}
public IVirtualPathProvider VirtualPathProvider { get; set; }
}
}