Moved over to using Ninject

This commit is contained in:
tidusjar 2016-06-29 17:06:58 +01:00
parent 36bbf3375c
commit 0e1f1ecd40
11 changed files with 383 additions and 90 deletions

View file

@ -28,6 +28,8 @@ using System;
using Nancy.TinyIoc;
using Ninject;
namespace PlexRequests.UI.Helpers
{
public class ServiceLocator : IServiceLocator
@ -37,21 +39,21 @@ namespace PlexRequests.UI.Helpers
Singleton = new ServiceLocator();
}
private static ServiceLocator Singleton { get; }
private TinyIoCContainer Container { get; set; }
private IKernel Container { get; set; }
public static ServiceLocator Instance => Singleton;
public void SetContainer(TinyIoCContainer con)
public void SetContainer(IKernel con)
{
Container = con;
}
public T Resolve<T>() where T : class
{
return Container?.Resolve<T>();
return Container?.Get<T>();
}
public object Resolve(Type type)
{
return Container.Resolve(type);
return Container.Get(type);
}
}