views:

14

answers:

1

To use your own ModelMetadataProvider you normally set it in the global.asax.

I'm using MVC Turbine and I need to inject a dependency into my ModelMetadataProvider as well.

Something like this:

ModelMetadataProviders.Current = new MyModelMetadataProvider(ISomeDependency);

How is this best accomplished with MVC Turbine?

A: 

The best place to put these pieces is to override the Startup method within your web application (the type that inherits from TurbineApplication). We're currently working on making these MVC2 features easier in v2.2 by introducing a ModelMetadataBlade that will do all the wiring up for you to the ModelMetadataProvider.Current property.

So all you'll have to do is register MyModelMetadataProvider with the container like so

container.Register<ModelMetadataProvider, MyModelMetadataProvider>()

then MVC Turbine will do the rest for you. To get an idea of what I'm talking about, checkout the way we're wiring up ModelValidatorProviders. The ModelValidatorBlade asks the ServiceLocator for all the registered ModelValidatorProvider and wires them up with the runtime.

If you have any feedback or ideas, could you post them to the Google Group? Trying to keep these things organized :)

Thanks!

Javier Lozano