Frage

Say, I have a LogAttribute class like this:

  public class LogAttribute : RequestFilterAttribute {
    public override void Execute(IHttpRequest req, 
                                 IHttpResponse res, 
                                 object dto) { /*...*/ }
  }    
  [Log]
  public class TransportService : Service { /*...*/ }
  [Log]
  public class HealthService : Service { /*...*/ }

How does the LogAttribute class know what class it is calling from? Namely, TransportService or HealthService?

War es hilfreich?

Lösung

You can use the Request DTO that's passed in as well as the metadata ServiceStack maintains about your service, e.g:

var serviceType = HostContext.Metadata.GetServiceTypeByRequest(dto.GetType());
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top