media-type improvements on the way
i am making some headway on the improved support for media-types this evening.
first, i cleaned up proper support for the static types (using the GetHandler
resource class. it's now simple to get proper caching and media-type support for the resource type. i actually cut out some code to get it working right - a good sign.
second, i converted the SupportedMediaTypes
property collection into the MediaTypes
custom attribute. that means that the storage of the supported media types for aa resource class is actually statically bound into the *compiled code* instead of being stored in the class instance at runtime. in the case of performing the content negotiation for the actual operations on the resource, this is really not any better than using the instance collection. but there is a huge advantage in storing this data in the code itself.
and that's because i can use this data during the cache-clearing operations. by storing the list of supported media-types this way, i can query the list of types are runtime (using reflection) to amek sure i use the proper - and complete) list of types to clear out of the cache. i still need to implement this part, but i know it's do-able. i just need to use the URL handed to the ClearCache
method to inspect the UriPattern
custom attribute of the compiled resource classes to find the one that matches. that will then allow me to pull the associated MediaTypes
custom attribute and use that to fire off the correctly formatted requests against the cache. sweet, right?
i have some pretty good example code that is used for the UriPattern
attribute. so i figure to use that as my guide to build the new code that will the work of locating the proper media-types. should be able to finish this over the weekend.