FlexitimeTracker/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Configuration.cs
Chris.Watts90@outlook.com ebfced87ee fix relative file paths (file not found errors).
added razor engine to WindowsDataCenter project.
fixed odd logCount errors in spa.js/index.html
2017-02-16 17:07:48 +00:00

46 lines
1.5 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Web;
using Interfaces;
using Ninject;
using Ninject.Web.Common;
namespace WindowsDataCenter
{
public static class Configuration
{
public static StandardKernel ConfigureNinject()
{
var kernel = new StandardKernel();
kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
var ninjectConfigPath =
new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), "NinjectConfig.xml"))
.LocalPath;
if (File.Exists(ninjectConfigPath))
{
kernel.Load(ninjectConfigPath);
}
var logger = kernel.TryGet<ILogger>();
if (logger == null)
{
kernel.Bind<ILogger>().To<DefaultComponents.DefaultLogger>();
logger = kernel.Get<ILogger>();
}
logger.Fatal("test message - ninject stuff loaded.");
var repo = kernel.TryGet<IRepository>();
if (repo == null)
{
Debug.WriteLine(File.ReadAllText(ninjectConfigPath));
logger.Fatal("A type of IRepository must be installed. Exiting.");
throw new ArgumentNullException("IRepository");
}
logger.Trace("Got Repo: {0}", repo.GetType());
return kernel;
}
}
}