I write some C# class libary and I want to use Ninject to provide dependency injection for my classes. Is it possible for class libary to declare some code (method) that would be executed each fime the class libary is loaded. I need this to define bindings for Ninject.
...
What is an IoC container?
What is an IoC/DI framework?
Why do we need a framework for IoC/DI?
Is there any relationship between IoC/DI and AOP?
What is Spring.net/ninject with respect to IoC and AOP?
...
I was reading over Injection by Hand and Ninjection (as well as Why use Ninject ). I encountered two pieces of confusion:
The inject by hand technique I am already familiar with, but I am not familiar with Ninjection, and thus am not sure how the complete program would work. Perhaps it would help to provide a complete program rather ...
I'm struggling with the documentation to figure out exactly what I need to. The documentation (to my understanding) is for 1.5 anyway.
N.B: I don't want to extend NinjectHttpApplication
I've configured it to use the NinejctControllerFactory in Application_Start() but I get a null reference exception on the KernelContainer.Kernel when i...
I am currently writing an open source SDK for a program that I use and I'm using an IoC container internally(NInject) to wire up all my internal dependencies.
I have some objects that are marked as internal so that I don't crowd the public API as they are only used internally and shouldn't been seen by the user, stuff like factories a...
I am pretty new to the NInject binding, and here is what NInject describes.
TransientBehavior-A new instance of the type will be created each time one is requested.
SingletonBehavior-Only a single instance of the type will be created, and the same instance will be returned for each subsequent request.
OnePerThreadBehavior-One instance ...
We are using ASP.net MVC.
Which of these is the best DI framework Ninject or Unity and why?
...
Hi,
Ninject looks great, so I'd like to use it in my project. Unfortunately I am still struggling to do the most trivial binding. The [Inject] attribute compiles just fine, but the compiler cannot find the "Bind" command:
using System;
using Ninject.Core;
using Ninject.Core.Binding;
namespace NinjectTest
{
public interface IFoo
...
I have some bindings that are setup as singletons. I want them to always return the same instance until a certain point at which I want all the singleton instances to be cleared. I don't want to remove and re-add the bindings, just clear out the instances that have been created. Is this possible?
...
Hi there,
is there a way to inject an object into the session state automatically with Ninject? For example:
I have a provider that gets me a list of objects.
In my views I have something that reads state from session like <%=Session["MyKey"].Data%>
Now I want to be able to inject the value of Session["MyKey"] with Ninject instead of ...
Ok Dependency Ninja's, here's one for you...
I want to change the way Ninject builds a dependency based upon the type I'm requesting from the Kernel.
I have a DbConnectionFactory class with the following constructors:
public DbConnectionFactory()
: this(MyDatabase.ConnectionString)
{
}
public DbConnectionFacto...
I have a WPF UserControl that I'd like to inject dependencies into. What's the best way to do this with Ninject?
To take a concrete example: I have a UserControl called MapView, and I want to inject an instance of my IDialogueService into it, via either constructor or property injection. Currently, I'm not using any dependency injection...
Hello,
I'm designing medium-size website using asp.net mvc technology.
All business logic is organized into IServices (like IDomainService, IUserService, IAuthService, ITrainingService). All services are using IRepositories.
I'm using Ninject 1.5 to wire services with controllers and it seems working perfectly.
There is so far one subj...
(Tried to post this on the ninject google group but it didn't show up so far, a few hours later..)
I have started using Ninject 2 (downloaded from Github yesterday including the MVC extension project) with a project based on the following technologies;
.Net 3.5 Sp1
ASP.NET MVC 1.0
LINQ to SQL
Nothing magical here - I have a few repo...
Following up on using dependency injection for WCF services, is there any way of using DI for WCF validators, so that one could do this:
public class DIValidator : UserNamePasswordValidator
{
private readonly IService service;
[Inject]
public DIValidator(IService service)
{
this.service = service;
}
pub...
In Ninject's dependency injection, if you set up a binding of a class to itself like so:
Bind<SomeClass>().ToSelf();
Ninject very nicely resolves any dependencies SomeClass has and gives you the object back. I want to be able to do something to the SomeClass it returns every time it creates a new one, so like a post-processing event....
I am planning out some work to introduce Dependency Injection into what is currently a large monolithic library in an attempt to make the library easier to unit-test, easier to understand, and possibly more flexible as a bonus.
I have decided to use NInject, and I really like Nate's motto of 'do one thing, do it well' (paraphrased), and...
I'm looking into doing a project in Silverlight 3 using Prism and I really like the eventing aggregation as shown here http://development-guides.silverbaylabs.org/Video/Prism-Eventing
All the resources seem to be pointing to using Unity with Prism and not Ninject. In Ninject is there a similar way of aggregating events? Or if I want to ...
I'm trying to set up Ninject for the first time. I've got an IRepository interface, and a Repository implementation. I'm using ASP.NET MVC, and I'm trying to inject the implementation like so:
public class HomeController : Controller
{
[Inject] public IRepository<BlogPost> _repo { get; set; }
public ActionResult Index()
{...
How do bind my interface to a concrete class in a different assembly?
I have the following projects in my solution:
Foo.Data
Foo.Domain
In Structure Map I add my two assembly names to the StructureMap.config file and a then using the PluginFamily and Pluggable attributes map my interfaces to my concrete class'.
How can accomplish t...