【问题标题】:PostSharp OnMethodBoundaryAspect - access parameters types from constructorPostSharp OnMethodBoundaryAspect - 从构造函数访问参数类型
【发布时间】:2015-06-25 09:26:45
【问题描述】:

我有一个 OnMethodBoundaryAspect 属性 (PostSharp),我希望能够使用来自使用方法参数的属性构造函数的表达式

让我们这样说:

[MyAttribute(p => p.SomeProperty)]
public void DoSomething(Parameter parameter)
{
    ....
}

p是类型参数

有可能吗?

谢谢

【问题讨论】:

    标签: c# .net postsharp aspect


    【解决方案1】:

    无法在属性构造函数中使用表达式树。

    根据您要解决的问题,可能会有一些方法可以实现您要解决的问题 - 例如您可以使用 PostSharp 分析方法主体并根据该信息动态应用方面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-23
      • 1970-01-01
      • 2015-11-05
      • 2020-07-11
      • 2011-08-03
      • 1970-01-01
      • 1970-01-01
      • 2018-12-08
      相关资源
      最近更新 更多