added come comments to explain setup and configuration of ninject and WebAPI.
This commit is contained in:
parent
1e8d56ab82
commit
de57353511
@ -8,12 +8,8 @@ using System.ServiceProcess;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
|
||||||
using System.Web.Http.Dependencies;
|
|
||||||
using Microsoft.Owin.Hosting;
|
using Microsoft.Owin.Hosting;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Ninject.Syntax;
|
|
||||||
using Ninject.Web.Common;
|
|
||||||
|
|
||||||
namespace WindowsDataCenter
|
namespace WindowsDataCenter
|
||||||
{
|
{
|
||||||
@ -40,16 +36,15 @@ namespace WindowsDataCenter
|
|||||||
|
|
||||||
protected override void OnStart(string[] args)
|
protected override void OnStart(string[] args)
|
||||||
{
|
{
|
||||||
|
//Initialise the Ninject system.
|
||||||
//initialise ninject kernel.
|
var ninjectInstance = NinjectHelper.GetInstance();
|
||||||
NinjectHelper.GetInstance(_dbConnection);
|
|
||||||
|
|
||||||
|
|
||||||
_mainWorkerThread = new Thread(MainWorkerThread)
|
_mainWorkerThread = new Thread(MainWorkerThread)
|
||||||
{
|
{
|
||||||
IsBackground = false,
|
IsBackground = false,
|
||||||
Name = "OWIN SELF HOST MAIN THREAD"
|
Name = "OWIN SELF HOST MAIN THREAD"
|
||||||
};
|
};
|
||||||
|
//TODO: use app.config for endpoint config.
|
||||||
_webApp = WebApp.Start<StartOwin>("http://localhost:8800");
|
_webApp = WebApp.Start<StartOwin>("http://localhost:8800");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,17 +8,13 @@ namespace WindowsDataCenter
|
|||||||
public void Configuration(IAppBuilder appBuilder)
|
public void Configuration(IAppBuilder appBuilder)
|
||||||
{
|
{
|
||||||
var config = new HttpConfiguration();
|
var config = new HttpConfiguration();
|
||||||
//config.Routes.MapHttpRoute(
|
|
||||||
// name: "DefaultApi",
|
|
||||||
// routeTemplate: "api/{controller}/{id}",
|
|
||||||
// defaults: new { id = RouteParameter.Optional }
|
|
||||||
//);
|
|
||||||
config.MapHttpAttributeRoutes();
|
config.MapHttpAttributeRoutes();
|
||||||
|
|
||||||
|
//ninject resolver for ApiController DI.
|
||||||
config.DependencyResolver = new NinjectDependencyResolver(NinjectHelper.GetInstance().Kernel);
|
config.DependencyResolver = new NinjectDependencyResolver(NinjectHelper.GetInstance().Kernel);
|
||||||
|
//JSONP formatter for cross-domain requests.
|
||||||
config.Formatters.Insert(0, new JsonpFormatter());
|
config.Formatters.Insert(0, new JsonpFormatter());
|
||||||
|
|
||||||
|
|
||||||
appBuilder.UseWebApi(config);
|
appBuilder.UseWebApi(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user