jeudi 18 août 2022

I can't access custom attribute in dispatch proxy invoke method in .netcore6

I cannot access the custom attribute I wrote for the method within the invoke method.

Attribute class :

public class HttpTypeAttribute : Attribute
{
    public string Type { get; set; }
    public HttpTypeAttribute(string type)
    {
        Type = type;
    }
}

Web function:

 [HttpType("POST")]
    public ResponseDTO Run(RequestDTO requestDTO)
    {
        var result = ProxyManager<TestInterface>.CreateProxy(url).Run(requestDTO);
        return result;
    }

Invoke method:

protected override object Invoke(MethodInfo targetMethod, object[] args)
    {
          
        HttpTypeAttribute attr = (HttpTypeAttribute)targetMethod.GetCustomAttributes(typeof(HttpTypeAttribute), true).FirstOrDefault();  // attr is null
          
    }

Is there any way to do this? I would be glad if you help.





Aucun commentaire:

Enregistrer un commentaire