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