说,我有一个像这样的LogAttribute类:
public class LogAttribute : RequestFilterAttribute {
public override void Execute(IHttpRequest req,
IHttpResponse res,
object dto) { /*...*/ }
}
[Log]
public class TransportService : Service { /*...*/ }
[Log]
public class HealthService : Service { /*...*/ }
LogAttribute类如何知道它从哪个类调用?即TransportService还是HealthService?
答案 0 :(得分:1)
您可以使用传入的Request DTO以及ServiceStack维护的有关您服务的元数据,例如:
var serviceType = HostContext.Metadata.GetServiceTypeByRequest(dto.GetType());