You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I could also implement the SynchronizationContext directly in the implementation Service1, but that would require me to have a lot of boilerplate in every service method that needs this (there is a lot).
Then, I could implement ServiceInterceptionDelegate to dynamically inspect Type serviceType, then optionally use Reflection.Emit to build a wrapping interface implementation that takes the original service as a parameter, and performing all my aspect-oriented concerns within.
I could see this also being used for diagnostics/timings/etc.
The text was updated successfully, but these errors were encountered:
Side question, is there a nifty .NET lib our there that would allow me to generate wrapping proxy classes for interfaces in this manner? I could Reflection.Emit myself, but I have to imagine there is something out there.
We're not planning to add this kind of feature to our built-in DI container at this time. It sounds like this more advanced scenario might be a good fit for plugging in a different DI container.
You're in luck - I wrote something to do AOP in Net Core (using the standard DI container) using Castle Proxy ;-) => https://github.com/f135ta/SimpleProxy
ghost
locked as resolved and limited conversation to collaborators
Dec 2, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have services registered that have methods that return
Task<T>
types.I have a requirement that any caller of these methods needs to run continuations on a single thread (with a custom
SynchronizationContext
).Right now, each caller of the service needs to manage the
SynchronizationContext
before calling the service.Any time I use
IService1
, I could manage theSynchronizationContext
myself, but I run the risk of having some callers forget to do so.I could also implement the
SynchronizationContext
directly in the implementationService1
, but that would require me to have a lot of boilerplate in every service method that needs this (there is a lot).I'd like to use an aspect-oriented approach to configuring an entire service (
IService
) to run continouations with a specificSynchronizationContext
.Or maybe even at the method level.
When building my
IServiceProvider
, I'd like to intercept and potentially replace any resolved service.I think I could implement this myself if
ServiceProviderEngine
waspublic
, but it isinternal
.Maybe we can add an optional delegate to
ServiceProviderOptions
?Then, I could implement
ServiceInterceptionDelegate
to dynamically inspectType serviceType
, then optionally useReflection.Emit
to build a wrapping interface implementation that takes the original service as a parameter, and performing all my aspect-oriented concerns within.I could see this also being used for diagnostics/timings/etc.
The text was updated successfully, but these errors were encountered: