Adding custom ValueProviderFactories to ASP.NET MVC3?

前端 未结 1 906
死守一世寂寞
死守一世寂寞 2021-02-06 04:48

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 co

1条回答
  •  粉色の甜心
    2021-02-06 05:33

    It turns out that it is not read only and you can add providers as follows:

    ValueProviderFactories.Factories.Add(new MyValueProviderFactory());
    

    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.

    0 讨论(0)
提交回复
热议问题