Mugen Injection [Binding events]
The MugenInjection exposes events that can be hooked at various stages in instance lifecycle:
- OnActivating - called before a component is used.
- OnActivated - called once a component is fully constructed. Here you can perform application-level tasks that depend on the component being fully constructed - these should be rare.
- OnReleaseObject - called before instances will be released, Here you can perform cleanup for a component.
- OnDisposed - executes callback method after binding disposed.
// Create your MugenInjector. _injector = new MugenInjector(); _injector.Bind<Beta>().ToSelf() .OnActivating(context => context.Parameters.Add(new ConstructorParameter("test", "test"))) .OnActivated(beta => beta.Test()) .OnDisposed(binding => {}) .OnReleaseObject((beta, b) => beta.CustomDispose()); _injector.Get<Beta>();