Exemplo n.º 1
0
        /// <summary>
        /// Creates a new <see cref="DefaultMetadataDetails"/>.
        /// </summary>
        /// <param name="key">The <see cref="ModelMetadataIdentity"/>.</param>
        /// <param name="attributes">The set of model attributes.</param>
        public DefaultMetadataDetails(ModelMetadataIdentity key, ModelAttributes attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            Key = key;
            ModelAttributes = attributes;
        }
        /// <summary>
        /// Creates a new <see cref="ValidationMetadataProviderContext"/>.
        /// </summary>
        /// <param name="key">The <see cref="ModelMetadataIdentity"/> for the <see cref="ModelMetadata"/>.</param>
        /// <param name="attributes">The attributes for the <see cref="ModelMetadata"/>.</param>
        public ValidationMetadataProviderContext(
            ModelMetadataIdentity key,
            ModelAttributes attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            Key = key;
            Attributes = attributes.Attributes;
            PropertyAttributes = attributes.PropertyAttributes;
            TypeAttributes = attributes.TypeAttributes;

            ValidationMetadata = new ValidationMetadata();
        }
 protected override DefaultMetadataDetails CreateTypeDetails(ModelMetadataIdentity key)
 {
     var entry = base.CreateTypeDetails(key);
     return new DefaultMetadataDetails(
         key,
         new ModelAttributes(_attributes.Concat(entry.ModelAttributes.TypeAttributes).ToArray()));
 }
 protected override DefaultMetadataDetailsCache CreateTypeCacheEntry(ModelMetadataIdentity key)
 {
     var entry = base.CreateTypeCacheEntry(key);
     return new DefaultMetadataDetailsCache(key, _attributes.Concat(entry.Attributes).ToArray());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a new <see cref="DefaultMetadataDetails"/>.
 /// </summary>
 /// <param name="key">The <see cref="ModelMetadataIdentity"/>.</param>
 /// <param name="attributes">The set of model attributes.</param>
 public DefaultMetadataDetails(ModelMetadataIdentity key, [NotNull] ModelAttributes attributes)
 {
     Key = key;
     ModelAttributes = attributes;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a new <see cref="ModelMetadata"/>.
        /// </summary>
        /// <param name="identity">The <see cref="ModelMetadataIdentity"/>.</param>
        protected ModelMetadata(ModelMetadataIdentity identity)
        {
            Identity = identity;

            InitializeTypeInformation();
        }
Exemplo n.º 7
0
 protected override DefaultMetadataDetails[] CreatePropertyDetails(ModelMetadataIdentity key)
 {
     var entries = base.CreatePropertyDetails(key);
     return entries.Select(e =>
     {
         return new DefaultMetadataDetails(
             e.Key,
             new ModelAttributes(_attributes.Concat(e.ModelAttributes.PropertyAttributes), e.ModelAttributes.TypeAttributes));
     })
     .ToArray();
 }
Exemplo n.º 8
0
 /// <summary>
 /// Creates a new <see cref="DefaultMetadataDetails"/>.
 /// </summary>
 /// <param name="key">The <see cref="ModelMetadataIdentity"/>.</param>
 /// <param name="attributes">The set of model attributes.</param>
 public DefaultMetadataDetails(ModelMetadataIdentity key, [NotNull] ModelAttributes attributes)
 {
     Key             = key;
     ModelAttributes = attributes;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Creates a new <see cref="ModelMetadata"/>.
 /// </summary>
 /// <param name="identity">The <see cref="ModelMetadataIdentity"/>.</param>
 protected ModelMetadata(ModelMetadataIdentity identity)
 {
     Identity = identity;
 }
 /// <summary>
 /// Creates a new <see cref="DefaultMetadataDetailsCache"/>.
 /// </summary>
 /// <param name="key">The <see cref="ModelMetadataIdentity"/>.</param>
 /// <param name="attributes">The set of model attributes.</param>
 public DefaultMetadataDetailsCache(ModelMetadataIdentity key, IReadOnlyList <object> attributes)
 {
     Key        = key;
     Attributes = attributes;
 }
            protected override DefaultMetadataDetailsCache CreateTypeCacheEntry(ModelMetadataIdentity key)
            {
                var entry = base.CreateTypeCacheEntry(key);

                return(new DefaultMetadataDetailsCache(key, _attributes.Concat(entry.Attributes).ToArray()));
            }
 /// <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([NotNull] ModelMetadataIdentity key)
 {
     return(new DefaultMetadataDetails(key, ModelAttributes.GetAttributesForType(key.ModelType)));
 }
 /// <summary>
 /// Creates a new <see cref="DefaultMetadataDetailsCache"/>.
 /// </summary>
 /// <param name="key">The <see cref="ModelMetadataIdentity"/>.</param>
 /// <param name="attributes">The set of model attributes.</param>
 public DefaultMetadataDetailsCache(ModelMetadataIdentity key, IReadOnlyList<object> attributes)
 {
     Key = key;
     Attributes = attributes;
 }