有谁知道如何获取发送到方法中的拦截参数。
例如...
您在 CustomerService 中有一个 Update 方法,如下所示.. Update(Customer c) ..并且您想要获取发送到服务中的 Customer 对象。
它是否以任何方式开箱即用,或者除了“通常”拦截之外我还必须做其他任何事情。
/J
最佳答案
假设您使用的是最新版本的 Ninject,您应该能够从拦截器 BeforeInvoke 调用参数中获取它们(如果您的拦截器继承自 SimpleInterceptor)
protected override void BeforeInvoke(Ninject.Core.Interception.IInvocation invocation)
{
foreach (var arg in invocation.Request.Arguments)
log.Message(arg.ToString());
}
请求字段中还提供了一些其他属性,可帮助您确定通用参数等内容。
关于parameters - Ninject AOP - 从拦截的方法中获取方法参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1320944/