add Ninject.Extensions.Xml to the packages list for CardReaderService. add NLogConfigFilePath configuration setting to the App.config file. added extra logging around Ninject loading. #34
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using CardReaderService.DefaultComponents;
|
|
using Interfaces;
|
|
using Ninject;
|
|
|
|
namespace CardReaderService
|
|
{
|
|
public static class Configuration
|
|
{
|
|
public static StandardKernel ConfigureNinject()
|
|
{
|
|
var kernel = new StandardKernel();
|
|
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<DefaultLogger>();
|
|
logger = kernel.Get<ILogger>();
|
|
}
|
|
logger.Fatal("test message - ninject stuff loaded.");
|
|
logger.Trace("NinjectConfig.xml is here: {0}", ninjectConfigPath);
|
|
logger.Trace("got logger: {0}", logger.GetType());
|
|
|
|
return kernel;
|
|
}
|
|
}
|
|
} |