/// <summary>
 /// Creates the <see cref="DefaultMetadataDetails"/> entry for a model <see cref="Type"/>.
 /// </summary>
 /// <param name="key">
 /// The <see cref="ModelMetadataIdentity"/> identifying the model <see cref="Type"/>.
 /// </param>
 /// <returns>A details object for the model <see cref="Type"/>.</returns>
 /// <remarks>
 /// The results of this method will be cached and used to satisfy calls to
 /// <see cref="GetMetadataForType(Type)"/>. Override this method to provide a different
 /// set of attributes.
 /// </remarks>
 protected virtual DefaultMetadataDetails CreateTypeDetails(ModelMetadataIdentity key)
 {
     return(new DefaultMetadataDetails(key, ModelAttributes.GetAttributesForType(key.ModelType)));
 }
Пример #2
0
 private ModelMetadataCacheEntry GetCacheEntry(ConstructorInfo constructor, Type modelType)
 {
     return(_modelMetadataCache.GetOrAdd(
                ModelMetadataIdentity.ForConstructor(constructor, modelType),
                _cacheEntryFactory));
 }
Пример #3
0
 private ModelMetadataCacheEntry GetCacheEntry(ParameterInfo parameter, Type modelType)
 {
     return(_modelMetadataCache.GetOrAdd(
                ModelMetadataIdentity.ForParameter(parameter, modelType),
                _cacheEntryFactory));
 }
Пример #4
0
 private ModelMetadataCacheEntry GetCacheEntry(PropertyInfo property, Type modelType)
 {
     return(_modelMetadataCache.GetOrAdd(
                ModelMetadataIdentity.ForProperty(property, modelType, property.DeclaringType !),
                _cacheEntryFactory));
 }
Пример #5
0
 protected virtual DefaultMetadataDetails CreateParameterDetails(ModelMetadataIdentity key)
 {
     return(new DefaultMetadataDetails(
                key,
                ModelAttributes.GetAttributesForParameter(key.ParameterInfo)));
 }