dependency injection - In Ninject, how can I run custom code on an object after it is created with Bind<..>.ToSelf()? -


In the dependency of Nanjject injection, if you set the bindings of a class as yourself:

  bind & lt; SomeClass & gt; () ToSelf () .;  

Ninject resolves any dependency very well and has some class and gives you back the object. I want to be able to do something for some class, it returns every time when a new processing event is created. I can use binding to make it new to Totemath (or tofetterm), but I would like to solve all my dependencies first by Ninject.

It would be good to do something like this:

Bind & lt; SomeClass & gt; (). Self (). After (sc = & gt; sc.MethodIWantToCall ()); // Then here, gives the negative object. Is it some way to do Ninject 1.0 / 1.1?

If you can not insert the code that you want to execute in constructor, then you IInitializable or IStartable . The former provides a initial () method that is said after all the injections are completed, and later both have a start () and stop () The method is called, respectively, during activation and deactivation.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -