/// <summary> /// Registers metadata provider and model metadata configuration classes /// </summary> public void Register() { var configurations = getConfigurations != null ? getConfigurations().Where(t => t != null) : Enumerable.Empty<IModelMetadataConfiguration>(); foreach (var configuration in configurations) { Registry.RegisterModelProperties(configuration.ModelType, configuration.Configurations); } IList<ModelValidatorProvider> validatorProviders = new List<ModelValidatorProvider>(ModelValidatorProviders.Providers); validatorProviders.Insert(0, new ExtendedModelValidatorProvider()); var compositeModelValidatorProvider = new CompositeModelValidatorProvider(validatorProviders.ToArray()); ModelMetadataProviders.Current = new ExtendedModelMetadataProvider(Registry); ModelValidatorProviders.Providers.Clear(); ModelValidatorProviders.Providers.Add(compositeModelValidatorProvider); }
/// <summary> /// Registers metadata provider and model metadata configuration classes /// </summary> public void Register() { var configurations = getConfigurations != null?getConfigurations().Where(t => t != null) : Enumerable.Empty <IModelMetadataConfiguration>(); foreach (var configuration in configurations) { Registry.RegisterModelProperties(configuration.ModelType, configuration.Configurations); } IList <ModelValidatorProvider> validatorProviders = new List <ModelValidatorProvider>(ModelValidatorProviders.Providers); validatorProviders.Insert(0, new ExtendedModelValidatorProvider()); var compositeModelValidatorProvider = new CompositeModelValidatorProvider(validatorProviders.ToArray()); ModelMetadataProviders.Current = new ExtendedModelMetadataProvider(Registry); ModelValidatorProviders.Providers.Clear(); ModelValidatorProviders.Providers.Add(compositeModelValidatorProvider); }