MvcExtensions / Core

MvcExtensions - Extend everything
Microsoft Public License
52 stars 17 forks source link

Standalone Fluent ModelMetadata configuration registration #1

Closed AlexBar closed 12 years ago

AlexBar commented 12 years ago

Added ability to use only Fluent ModelMetadata configuration without bootstrapping features of MvcExtensions.

Usage (example with Autofac):

// Global.asax.cs
protected void Application_Start()
{
     AreaRegistration.RegisterAllAreas();

     RegisterGlobalFilters(GlobalFilters.Filters);
     RegisterRoutes(RouteTable.Routes);

     ContainerBuilder builder = new ContainerBuilder();

     var current = ModelMetadataRegistrar.Current;
     current.RegisterMetadataTypes(
                (serviceType, implType) => builder.RegisterType(implType).As(serviceType).InstancePerDependency(),
                (serviceType, implType) => builder.RegisterType(implType).As(serviceType).SingleInstance());

     DependencyResolver.SetResolver(new AutofacDependencyResolver(builder.Build()));

     current.RegisterMetadataProviders(DependencyResolver.Current);
}
hazzik commented 12 years ago

I suppose that it would be greater if user would register all the metadata configuration by himself. So we can waste the RegisterMetadataTypes method as useless abstraction on IoC container.

AlexBar commented 12 years ago

ok, removed it

AlexBar commented 12 years ago

the changes are integrated into pull request #5 - https://github.com/MvcExtensions/Core/pull/5