parameters - Ninject AOP - 从拦截的方法中获取方法参数

标签 parameters aop ninject

有谁知道如何获取发送到方法中的拦截参数。

例如...

您在 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/

相关文章:

c# - NLog 找不到或加载配置文件

android - 如何在 Android 中将方法作为参数传递?

c++ - 什么可能导致 `MyType *pType` 在返回时从有效参数变为 null?

java - 字段初始化后执行方法

Spring AOP : Annotation on any method called x not working

java - Spring AOP 关于注解 Controller 的建议

c++ - 模板函数中的默认参数 (C++)

c# - 使用无名参数执行存储过程

rhino-mocks - 自动模拟容器 : Rhino Mocks and NInject

c# - 根据配置解析不同的实例