If my service have some initialization code, I know two options:
Implement ISupportInitialize.
Pro: Only depend on .NET native interface.
Con: I normally only use BeginInit(), so there's always unneccessary code of empty EndInit()
Implement Castle Core's IInitializable.
Pro: Only one method needs to be implemented.
Con: I have to make my class depend on Castle Core.
Is there a better alternative?
Yes there is:
Component.For<Foo>().OnCreate(foo => foo.WhateverMethodYouWant());
The details are in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With