Replies: 2 comments 3 replies
|
I was thinking to steal properties from target, especially a public class SomeAdvice : Attribute, IMethodAdvice
{
public void Advise(MethodAdviceContext context)
{
// -- some samples here:
// find a value of type IServiceProvider in target
var serviceProvider = context.GetMember<IServiceProvider>();
// use a direct value or IServiceProvider
var serviceProvider = context.GetMemberService<SomeService>();
// the above is equivalent to
var serviceProvider2 = (SomeService)context.GetMember<IServiceProvider>()?.GetService(typeof(SomeService))
?? context.GetMember<SomeService>();
// then proceed
context.Proceed();
}
}Fun fact: this does not require any addition to MrAdvice core, but can be implemented as an extension class. |
1 reply
|
Hello, thanks for your efforts.
I' not sure i understand that. What would this extension class look like to to make the |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
In issue #175, a discussion about DI was opened.
There was a post where options are shown.
The post above and referenced issues raise some questions:
This is the time to see big, not to copy what others do.
All reactions