I am wondering if Ninject’s kernel Get() function retrieve’s one instanciated instance in the following snippet:
_kernel = new StandardKernel();
CreateBindings();
ICard card = _kernel.Get<ICard>();
ICard card2 = _kernel.Get<ICard>();
Does card and card2 point to the same instance or do they point to two separate instances? Also, if I had an ICard[] and I wanted to fill the array with 10 unique instances of ICard, how can I do this?
It depends on how binding for that type has been configured. If binding is singleton, both instances would be the same:
However when you use default binding, both instances will be different:
To fill array use the following code: