This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Using Ninject
Acoustic edited this page Sep 14, 2010
·
5 revisions
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!