我有一个wpf应用程序,我想在其中使用NInject作为依赖注入器
所以我创建了Dependency Resolver
类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using Ninject.Parameters;
using Ninject.Syntax;
namespace NinjectWithWPF
{
public class DependencyResolution
{
public IKernel kernel;
public DependencyResolution()
{
kernel = new StandardKernel();
AddBindings();
}
private void AddBindings()
{
kernel.Bind<Icalcul>().To<CalculSimple>();
}
public object GetService(Type serviceType)
{
return kernel.TryGet(serviceType);
}
public IEnumerable<Object> GetServices(Type serviceType)
{
return kernel.GetAll(serviceType);
}
}
}
我需要知道如何在App.xaml
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using Ninject;
using Ninject.Parameters;
using Ninject.Syntax;
namespace NinjectWithWPF
{
/// <summary>
/// Logique d'interaction pour App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
}
}
}
所以我需要知道