Ninject transient scope?

Then pass a factory function to the constructor: public ctor(Func classFactory) { this. ClassFactory = classFactory; } And create an instance where required this way: this.classFactory() NOTE: I think it is not a good design to pass a new instance to others using a property as in your question. If a class that has this one as dependency you should rather use the mechanism from above inside this other class or if only a single instance is required then use constructor injection instead.

Then pass a factory function to the constructor: public ctor(Func classFactory) { this. ClassFactory = classFactory; } And create an instance where required this way: this.classFactory(); NOTE: I think it is not a good design to pass a new instance to others using a property as in your question. If a class that has this one as dependency you should rather use the mechanism from above inside this other class or if only a single instance is required then use constructor injection instead.

1 I had queued up a 'task' to answer in the exact same manner! – Ruben Bartelink Apr 29 at 8:05.

In this situation, you want the Factory pattern. Instead of injecting an instance of a type, you inject a factory object and then invoke that method. To use a simple example: Inject public ISomeFactory SomeFactory { get; set; } public IClass Instance { get { return SomeFactory.CreateNew(); } }.

(And I think you should convert it to Constructor Injection too but thats less critical) – Ruben Bartelink Apr 29 at 8:06 Correct - I was just giving a simple example. The factory pattern is more important. – Tejs Apr 29 at 14:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions