ModelMetadata Class

A metadata representation of a model type, property or parameter.

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

Syntax

[DebuggerDisplay("{DebuggerToString(),nq}")]
public abstract class ModelMetadata : IEquatable<ModelMetadata>
class Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata

Methods

Equals(Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata)
Return type:System.Boolean
public bool Equals(ModelMetadata other)
Equals(System.Object)
Return type:System.Boolean
public override bool Equals(object obj)
GetDisplayName()

Gets a display name for the model.

Return type:System.String
Returns:The display name.
public string GetDisplayName()
GetHashCode()
Return type:System.Int32
public override int GetHashCode()

Constructors

ModelMetadata(Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity)

Creates a new Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.

Arguments:identity (Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity) – The Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity.
protected ModelMetadata(ModelMetadataIdentity identity)

Properties

Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.AdditionalValues

Gets a collection of additional information about the model.

Return type:System.Collections.Generic.IReadOnlyDictionary<System.Object>
public abstract IReadOnlyDictionary<object, object> AdditionalValues { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.BinderModelName

Gets the name of a model if specified explicitly using Microsoft.AspNetCore.Mvc.ModelBinding.IModelNameProvider.

Return type:System.String
public abstract string BinderModelName { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.BinderType

Gets the System.Type of an Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder of a model if specified explicitly using Microsoft.AspNetCore.Mvc.ModelBinding.IBinderTypeProviderMetadata.

Return type:System.Type
public abstract Type BinderType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.BindingSource

Gets a binder metadata for this model.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource
public abstract BindingSource BindingSource { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ContainerType

Gets the container type of this metadata if it represents a property, otherwise <code>null</code>.

Return type:System.Type
public Type ContainerType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ConvertEmptyStringToNull

Gets a value indicating whether or not to convert an empty string value to <code>null</code> when representing a model as text.

Return type:System.Boolean
public abstract bool ConvertEmptyStringToNull { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.DataTypeName

Gets the name of the model’s datatype. Overrides Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType in some display scenarios.

Return type:System.String
Returns:<code>null</code> unless set manually or through additional metadata e.g. attributes.
public abstract string DataTypeName { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.Description

Gets the description of the model.

Return type:System.String
public abstract string Description { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.DisplayFormatString

Gets the composite format System.String (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx) used to display the model.

Return type:System.String
public abstract string DisplayFormatString { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.DisplayName

Gets the display name of the model.

Return type:System.String
public abstract string DisplayName { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.EditFormatString

Gets the composite format System.String (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx) used to edit the model.

Return type:System.String
public abstract string EditFormatString { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ElementMetadata

Gets the Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata for elements of Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType if that System.Type implements System.Collections.IEnumerable.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata
Returns:Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata for <code>T</code> if Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType implements System.Collections.Generic.IEnumerable`1. Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata for <code>object</code> if Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType implements System.Collections.IEnumerable but not System.Collections.Generic.IEnumerable`1. <code>null</code> otherwise i.e. when Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsEnumerableType is <code>false</code>.
public abstract ModelMetadata ElementMetadata { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ElementType

Gets the System.Type for elements of Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType if that System.Type implements System.Collections.IEnumerable.

Return type:System.Type
public Type ElementType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.EnumGroupedDisplayNamesAndValues

Gets the ordered and grouped display names and values of all System.Enum values in Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.UnderlyingOrModelType.

Return type:System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<Microsoft.AspNetCore.Mvc.ModelBinding.EnumGroupAndName>>
Returns:An System.Collections.Generic.IEnumerable`1 of System.Collections.Generic.KeyValuePair`2 of mappings between System.Enum field groups, names and values. <code>null</code> if Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsEnum is <code>false</code>.
public abstract IEnumerable<KeyValuePair<EnumGroupAndName, string>> EnumGroupedDisplayNamesAndValues { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.EnumNamesAndValues

Gets the names and values of all System.Enum values in Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.UnderlyingOrModelType.

Return type:System.Collections.Generic.IReadOnlyDictionary<System.String>
Returns:An System.Collections.Generic.IReadOnlyDictionary`2 of mappings between System.Enum field names and values. <code>null</code> if Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsEnum is <code>false</code>.
public abstract IReadOnlyDictionary<string, string> EnumNamesAndValues { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.HasNonDefaultEditFormat

Gets a value indicating whether Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.EditFormatString has a non-<code>null</code>, non-empty value different from the default for the datatype.

Return type:System.Boolean
public abstract bool HasNonDefaultEditFormat { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.HideSurroundingHtml

Gets a value indicating whether the “HiddenInput” display template should return <code>string.Empty</code> (not the expression value) and whether the “HiddenInput” editor template should not also return the expression value (together with the hidden <input> element).

Return type:System.Boolean
public abstract bool HideSurroundingHtml { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.HtmlEncode

Gets a value indicating whether the value should be HTML-encoded.

Return type:System.Boolean
Returns:If <code>true</code>, value should be HTML-encoded. Default is <code>true</code>.
public abstract bool HtmlEncode { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.Identity

Gets the key for the current instance.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataIdentity
protected ModelMetadataIdentity Identity { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsBindingAllowed

Gets a value indicating whether or not the model value can be bound by model binding. This is only applicable when the current instance represents a property.

Return type:System.Boolean
public abstract bool IsBindingAllowed { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsBindingRequired

Gets a value indicating whether or not the model value is required by model binding. This is only applicable when the current instance represents a property.

Return type:System.Boolean
public abstract bool IsBindingRequired { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsCollectionType

Gets a value indicating whether or not Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType is a collection type.

Return type:System.Boolean
public bool IsCollectionType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsComplexType

Gets a value indicating whether Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType is a simple type.

Return type:System.Boolean
public bool IsComplexType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsEnum

Gets a value indicating whether Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.UnderlyingOrModelType is for an System.Enum.

Return type:System.Boolean
Returns:<code>true</code> if <code>type.IsEnum</code> (<code>type.GetTypeInfo().IsEnum</code> for DNX Core 5.0) is <code>true</code> for Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.UnderlyingOrModelType; <code>false</code> otherwise.
public abstract bool IsEnum { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsEnumerableType

Gets a value indicating whether or not Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType is an enumerable type.

Return type:System.Boolean
public bool IsEnumerableType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsFlagsEnum

Gets a value indicating whether Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.UnderlyingOrModelType is for an System.Enum with an associated System.FlagsAttribute.

Return type:System.Boolean
Returns:<code>true</code> if Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsEnum is <code>true</code> and Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.UnderlyingOrModelType has an associated System.FlagsAttribute; <code>false</code> otherwise.
public abstract bool IsFlagsEnum { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsNullableValueType

Gets a value indicating whether or not Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType is a System.Nullable`1.

Return type:System.Boolean
public bool IsNullableValueType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsReadOnly

Gets a value indicating whether or not the model value is read-only. This is only applicable when the current instance represents a property.

Return type:System.Boolean
public abstract bool IsReadOnly { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsReferenceOrNullableType

Gets a value indicating whether or not Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType allows <code>null</code> values.

Return type:System.Boolean
public bool IsReferenceOrNullableType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.IsRequired

Gets a value indicating whether or not the model value is required. This is only applicable when the current instance represents a property.

Return type:System.Boolean
public abstract bool IsRequired { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.MetadataKind

Gets a value indicating the kind of metadata element represented by the current instance.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.ModelMetadataKind
public ModelMetadataKind MetadataKind { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelBindingMessageProvider

Gets the Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IModelBindingMessageProvider instance.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.IModelBindingMessageProvider
public abstract IModelBindingMessageProvider ModelBindingMessageProvider { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType

Gets the model type represented by the current instance.

Return type:System.Type
public Type ModelType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.NullDisplayText

Gets the text to display when the model is <code>null</code>.

Return type:System.String
public abstract string NullDisplayText { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.Order

Gets a value indicating where the current metadata should be ordered relative to other properties in its containing type.

Return type:System.Int32
Returns:The order value of the current metadata.
public abstract int Order { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.Placeholder

Gets the text to display as a placeholder value for an editor.

Return type:System.String
public abstract string Placeholder { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.Properties

Gets the collection of Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata instances for the model’s properties.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.ModelPropertyCollection
public abstract ModelPropertyCollection Properties { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.PropertyFilterProvider

Gets the Microsoft.AspNetCore.Mvc.ModelBinding.IPropertyFilterProvider, which can determine which properties should be model bound.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.IPropertyFilterProvider
public abstract IPropertyFilterProvider PropertyFilterProvider { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.PropertyGetter

Gets a property getter delegate to get the property value from a model object.

Return type:System.Func<System.Object>
public abstract Func<object, object> PropertyGetter { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.PropertyName

Gets the property name represented by the current instance.

Return type:System.String
public string PropertyName { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.PropertySetter

Gets a property setter delegate to set the property value on a model object.

Return type:System.Action<System.Object>
public abstract Action<object, object> PropertySetter { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ShowForDisplay

Gets a value that indicates whether the property should be displayed in read-only views.

Return type:System.Boolean
public abstract bool ShowForDisplay { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ShowForEdit

Gets a value that indicates whether the property should be displayed in editable views.

Return type:System.Boolean
public abstract bool ShowForEdit { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.SimpleDisplayProperty

Gets a value which is the name of the property used to display the model.

Return type:System.String
public abstract string SimpleDisplayProperty { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.TemplateHint

Gets a string used by the templating system to discover display-templates and editor-templates.

Return type:System.String
public abstract string TemplateHint { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.UnderlyingOrModelType

Gets the underlying type argument if Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType inherits from System.Nullable`1. Otherwise gets Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ModelType.

Return type:System.Type
public Type UnderlyingOrModelType { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ValidateChildren

Gets a value that indicates whether properties or elements of the model should be validated.

Return type:System.Boolean
public abstract bool ValidateChildren { get; }
Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.ValidatorMetadata

Gets a collection of metadata items for validators.

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

Fields

DefaultOrder()

The default value of Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.Order.

Return type:System.Int32
public static readonly int DefaultOrder