I have already done the following:
I would like to accomplish this:
Everytime I ask for any resolution from unity, if that object implements ILoggableObject, automatically inject the ILogger interface via the Hook method.
I think this is possible via interception or policies?
Any help would be awesome.
What you are looking for is TypeInterception in Unity. See here: http://msdn.microsoft.com/en-us/library/ff660861(PandP.20).aspx
Also here http://msdn.microsoft.com/en-us/library/ff660848(v=PandP.20).aspx
You want to intercept the call to the constructor and inject the Logger on behalf of the calling code without them being any wiser.
While I haven't done it before I believe you can do what you want using Intercept.NewInstance() http://msdn.microsoft.com/en-us/library/ff662093(PandP.20).aspx
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