I was looking to try and add a Protobuf ValueProviderFactory to MVC3 so that I could pick out the MIME type and deserialize the raw data into objects for action parameters. I could also use this to change the default Json serializer.
JsonValueProviderFactory.cs this shouldn't be too difficult, but the factories all appear to be hard-coded.
For Protobuf I may be able to do something with an IValueProvider but I haven't even checked yet what MVC3 does when it recieves an MIME type of
Am I going about this the right way?
I found this blog post that talks about creating an
IValueProvider. It then mentions at the bottom that this changed around MCV2. He changed it to a
ValueProviderFactory and calls :
But in MVC3 this property is read only.
It turns out that it is not read only and you can add providers as follows:
I would have know this had I checked myself!
I've done some more searching today, and this blog post seems to suggest that the
DependencyResolver will find any classes that inherit
ValueProviderFactory. I'm using MEF for dependency resolution so I can just add an Export attribute and it'll get picked up automatically.
I now have a further issue writing a custom ValueProviderFactory for protobuf-net.