I have a quick architectural question.
In my pursuit to do caching in our services, Ideally, my first thought was that I want to add some new attributes to request DTO’s that govern how service methods should behave (i.e. whether they run caching code or not, what the cache options they should have if they do (i.e TTL, PerUser, PerRequest etc.), and what response headers to return if they do).
So it would seem, I need a way for a service method to access some data that is provided/set by attributes that are declared on the request DTO. If that is possible?
For example:
[MyAttribute(SomeOptions)]
public class RequestDto : IReturn<ResponseDto>
{
}
internal class MyService : Service
{
public object Get(RequestDto request)
{
// Want to change what code executes here based on whether or not the 'request' variable for this method has [MyAttribute] defined on its DTO class or not. And if so, how to get any data provided to that attribute (or data provided by that attribute)
}
}
OR should I be using a different approach to achieve the same thing?