// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; namespace Microsoft.AspNet.Mvc.ModelBinding { /// /// An that provides base instances and does not /// set most properties. For example this provider does not use data annotations. /// /// /// Provided for efficiency in scenarios that require minimal information. /// public class EmptyModelMetadataProvider : AssociatedMetadataProvider { /// /// Ignores . protected override ModelMetadata CreateMetadataPrototype(IEnumerable attributes, Type containerType, [NotNull] Type modelType, string propertyName) { return new ModelMetadata( this, containerType, modelAccessor: null, modelType: modelType, propertyName: propertyName); } /// /// /// Copies very few values from the . Likely has not /// been modified except to add entries. /// protected override ModelMetadata CreateMetadataFromPrototype([NotNull] ModelMetadata prototype, Func modelAccessor) { var metadata = new ModelMetadata( this, prototype.ContainerType, modelAccessor, prototype.ModelType, prototype.PropertyName); foreach (var keyValuePair in prototype.AdditionalValues) { metadata.AdditionalValues.Add(keyValuePair); } return metadata; } } }