Using Ninject - TylerBrinks/Snap GitHub Wiki
| Dependency | Version |
| Snap | Current |
| Snap.Ninject.dll | Current |
| Ninject.dll | v2.0 |
Ninject uses the concept of a kernel as to create object instances. Because kernels are instantiated objects, it’s necessary to use Snap’s instance-based fluent configuration.
// Create a Snap.Ninject.NinjectAspectContainer
var container = new NinjectAspectContainer();
// Configure Snap to use Ninject using the container instance
SnapConfiguration.For(container).Configure(c =>
{
c.IncludeNamespace("My.Namespace.Root");
//c.IncludeNamespace("My.Namespace*");
c.Bind<HandleErrorInterceptor>().To<HandleErrorAttribute>();
});
Ninject is now fully configured to build proxied instances that will run your configured interceptors.
// Register your own types with the Ninject kernel. container.Kernel.Bind<IMyType>().To<MyType>(); // Get an AoP wrapped instance of your type from Ninject var instance = container.Kernel.Get<IMyType>();
Happy coding!