MvcExtensions / Core

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

Moved ModelMetadata registration into separate assembly #5

Closed AlexBar closed 12 years ago

AlexBar commented 12 years ago

Model metadata registration improvement: it was moved into separate assembly without any dependency from Core library.

Now user can use the following syntax to register model metadata (see examples https://gist.github.com/3322501):

  1. MvcExtensionsMetadataRegistrar.Register() simple way to register your configurations (metadata configuration classes must have default contrucotor)
  2. Register metadata configuration classes with IoC, then setup configuration factory:

For example, Windsor:

          MvcExtensionsMetadataRegistrar
                .RegisterEachConfigurationWithContainer(
                    data => container.Register(
                        Component
                            .For(data.InterfaceType).ImplementedBy(data.MetadataConfigurationType)
                            .LifestyleTransient()))
                .ConstructMetadataUsing(container.ResolveAll<IModelMetadataConfiguration>)
                .Register();

Autofac:

            var builder = new ContainerBuilder();
            MvcExtensionsMetadataRegistrar
                .RegisterEachConfigurationWithContainer(r => builder.RegisterType(r.MetadataConfigurationType).As(r.InterfaceType));

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

            MvcExtensionsMetadataRegistrar.Register();

See more https://gist.github.com/3322501

hazzik commented 12 years ago

Thanks, commited with squash to master 8abddc726be110a4174c971bccc2de0fdb38cff8