martinothamar/Mediator

Injecting options into handlers via DI container?

djflan opened this issue · 5 comments

Is it currently possible to inject options via the built in DI container using source generation?

Do you mean inject options to confingure Mediator itself (e.g. namespace)? That's not possible siden source generation depends on it. So the configuration values have to be constants

But other than that Mediator doesn't impose any limitations on how you use DI

nope, sorry - I meant to close this. I figured out how to do this.

Pretty sure this is what he was trying to do Martin, which is also what I am trying to figure out as well. If you want I can open a new ticker, or we can continue on this ticket. I really need to figure out how to do this.

@djflan I really wish you had shared your solution so that others could have benefited,

LOL, actually like @djflan I just tried it, and it just works. Like normal. Which was unexpected, and very nice. Sorry, this ticket can stay closed.

Ahh, so just injecting the MediatorOptions into some service at runtime? That should be possible yes.. Only constraint Mediator imposes is that the values put into the option properties are compile time constants (the source generator needs to see them)