감사 작업을하고 있으며 추가 정보를 얻기 위해 감사에 기록해야하는 메서드에 매개 변수를 표시하기 위해 특성을 사용하려고합니다. 그러나 어떤 이유로 든 속성이 존재하는지 여부를 확인할 수 없습니다.매개 변수 특성이 표시되지 않습니다.
내 코드 :
[Audit(AuditType.GetReport)]
public Stream GetReportStream([AuditParameter] Report report)
{
...
}
[AttributeUsage(AttributeTargets.Parameter)]
public class AuditParameterAttribute : Attribute
{
}
, 나는 그것을 얻기 위해 노력하고있어 요격 내부 :
foreach (ParameterInfo param in invocation.Method.GetParameters())
{
var atts = CustomAttributeData.GetCustomAttributes (param);
if (param.IsDefined (typeof(AuditParameterAttribute), false))
{
attributes.Add (param.Name, invocation.Arguments[param.Position].ToString());
}
}
내가 일을 뭔가를 얻으려고하는 몇 가지 추가 통화에 추가 시작; 왜 여분의 var atts
이 거기에 있는지요. invocation
변수는 호출 된 메서드에 대한 정보를 가지고 있으며 매개 변수를 나타내는 ParameterInfo 개체를 가져올 수 있습니다. 하지만, 내가 뭘했는지에 상관없이 나는 결코 사용자 정의 속성을 얻을 수 없다.
내가 뭘 잘못하고 있니?