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. |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for your efforts.
I' not sure i understand that. What would this extension class look like to to make the |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions