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>(); this.RequestFilters = new List>(); this.ResponseFilters = new List>(); this.ViewEngines = new List(); this.CatchAllHandlers = new List(); VirtualPathProvider = new FileSystemVirtualPathProvider(this, "~".MapServerPath()); } public void RegisterAs() where T : TAs { this.Container.RegisterAs(); } public virtual void Release(object instance) { } public void OnEndRequest() {} public void Register(T instance) { this.Container.Register(instance); } public T TryResolve() { return this.Container.TryResolve(); } public Container Container { get; set; } public IContentTypeFilter ContentTypeFilters { get; set; } public List> PreRequestFilters { get; set; } public List> RequestFilters { get; set; } public List> ResponseFilters { get; set; } public List ViewEngines { get; set; } public Action ExceptionHandler { get; set; } public List CatchAllHandlers { get; set; } public Dictionary> 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 Dictionary ResponseBinders { get { throw new NotImplementedException(); } } public IVirtualPathProvider VirtualPathProvider { get; set; } } }