How to Inject Interface in Aspect #211
MajidMoghise
started this conversation in
General
Replies: 1 comment
-
|
Please see #166 |
Beta Was this translation helpful? Give feedback.
0 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.
-
I want to inject Interface in Aspect For example inject Ilogger or IserviceProvider interface or Any interface in constructor
[Aspect(Scope.Global)] [Injection(typeof(LogCall))] public class LogCall : Attribute { private readonly ILogger<LogCall> _logger; public LogCall(ILogger<LogCall> logger) { _logger = logger; } [Advice(Kind.Before)] public void LogEnter([Argument(Source.Name)] string name, [Argument(Source.Arguments)] object[] objcts) { _logger.Information($"Calling '{name}'( " + JsonConvert.SerializeObject(objcts) + " )"); } [Advice(Kind.After)] public void LogOut([Argument(Source.Name)] string name, [Argument(Source.ReturnValue)] object objcts) { _logger.Information($"Out '{name}'( " + JsonConvert.SerializeObject(objcts) + " )"); }Beta Was this translation helpful? Give feedback.
All reactions