ModelAttributes Class

Provides access to the combined list of attributes associated a System.Type or property.

Namespace
Microsoft.AspNetCore.Mvc.ModelBinding
Assemblies
  • Microsoft.AspNetCore.Mvc.Core

Syntax

public class ModelAttributes
class Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes

Constructors

ModelAttributes(System.Collections.Generic.IEnumerable<System.Object>)

Creates a new Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes for a System.Type.

Arguments:typeAttributes (System.Collections.Generic.IEnumerable<System.Object>) – The set of attributes for the System.Type.
public ModelAttributes(IEnumerable<object> typeAttributes)
ModelAttributes(System.Collections.Generic.IEnumerable<System.Object>, System.Collections.Generic.IEnumerable<System.Object>)

Creates a new Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes for a property.

Arguments:
  • propertyAttributes (System.Collections.Generic.IEnumerable<System.Object>) – The set of attributes for the property.
  • typeAttributes (System.Collections.Generic.IEnumerable<System.Object>) – The set of attributes for the property’s System.Type. See System.Reflection.PropertyInfo.PropertyType.
public ModelAttributes(IEnumerable<object> propertyAttributes, IEnumerable<object> typeAttributes)

Properties

Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes.Attributes

Gets the set of all attributes. If this instance represents the attributes for a property, the attributes on the property definition are before those on the property’s System.Type.

Return type:System.Collections.Generic.IReadOnlyList<System.Object>
public IReadOnlyList<object> Attributes { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes.PropertyAttributes

Gets the set of attributes on the property, or <code>null</code> if this instance represents the attributes for a System.Type.

Return type:System.Collections.Generic.IReadOnlyList<System.Object>
public IReadOnlyList<object> PropertyAttributes { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes.TypeAttributes

Gets the set of attributes on the System.Type. If this instance represents a property, then Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes.TypeAttributes contains attributes retrieved from System.Reflection.PropertyInfo.PropertyType.

Return type:System.Collections.Generic.IReadOnlyList<System.Object>
public IReadOnlyList<object> TypeAttributes { get; }

Methods

GetAttributesForProperty(System.Type, System.Reflection.PropertyInfo)

Gets the attributes for the given <em>property</em>.

Arguments:
  • type (System.Type) – The System.Type in which caller found <em>property</em>.
  • property (System.Reflection.PropertyInfo) – A System.Reflection.PropertyInfo for which attributes need to be resolved.
Return type:

Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes

Returns:

A Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes instance with the attributes of the property.

public static ModelAttributes GetAttributesForProperty(Type type, PropertyInfo property)
GetAttributesForType(System.Type)

Gets the attributes for the given <em>type</em>.

Arguments:type (System.Type) – The System.Type for which attributes need to be resolved.
Return type:Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes
Returns:A Microsoft.AspNetCore.Mvc.ModelBinding.ModelAttributes instance with the attributes of the System.Type.
public static ModelAttributes GetAttributesForType(Type type)