ModelMetadata Class

Summary

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

Syntax

public abstract class ModelMetadata

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata

Fields

DefaultOrder()

The default value of [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.Order](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml).

public static readonly int DefaultOrder

Constructors

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

Creates a new [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml).

Arguments:
protected ModelMetadata(ModelMetadataIdentity identity)

Properties

AdditionalValues()

Gets a collection of additional information about the model.

Return type:System.Collections.Generic.IReadOnlyDictionary{System.Object,System.Object}
public abstract IReadOnlyDictionary<object, object> AdditionalValues { get; }
BinderModelName()

Gets the name of a model if specified explicitly using [Microsoft.AspNet.Mvc.ModelBinding.IModelNameProvider](Microsoft.AspNet.Mvc.ModelBinding.IModelNameProvider.yml).

Return type:System.String
public abstract string BinderModelName { get; }
BinderType()

Gets the [System.Type]() of an [Microsoft.AspNet.Mvc.ModelBinding.IModelBinder](Microsoft.AspNet.Mvc.ModelBinding.IModelBinder.yml) of a model if specified explicitly using [Microsoft.AspNet.Mvc.ModelBinding.IBinderTypeProviderMetadata](Microsoft.AspNet.Mvc.ModelBinding.IBinderTypeProviderMetadata.yml).

Return type:System.Type
public abstract Type BinderType { get; }
BindingSource()

Gets a binder metadata for this model.

Return type:Microsoft.AspNet.Mvc.ModelBinding.BindingSource
public abstract BindingSource BindingSource { get; }
ContainerType()

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

Return type:System.Type
public Type ContainerType { get; }
ConvertEmptyStringToNull()

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

Return type:System.Boolean
public abstract bool ConvertEmptyStringToNull { get; }
DataTypeName()

Gets the name of the model’s datatype. Overrides [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) in some display scenarios.

Return type:System.String
public abstract string DataTypeName { get; }
Description()

Gets the description of the model.

Return type:System.String
public abstract string Description { get; }
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; }
DisplayName()

Gets the display name of the model.

Return type:System.String
public abstract string DisplayName { get; }
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; }
ElementMetadata()

Gets the [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) for elements of [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) if that [System.Type]() implements [System.Collections.IEnumerable]().

Return type:Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata
public abstract ModelMetadata ElementMetadata { get; }
EnumDisplayNamesAndValues()

Gets the ordered display names and values of all [System.Enum]() values in [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) or

<c>Nullable.GetUnderlyingType(ModelType)</c>.

Return type:System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}}
public abstract IEnumerable<KeyValuePair<string, string>> EnumDisplayNamesAndValues { get; }
EnumNamesAndValues()

Gets the names and values of all [System.Enum]() values in [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) or

<c>Nullable.GetUnderlyingType(ModelType)</c>.

Return type:System.Collections.Generic.IReadOnlyDictionary{System.String,System.String}
public abstract IReadOnlyDictionary<string, string> EnumNamesAndValues { get; }
HasNonDefaultEditFormat()

Gets a value indicating whether [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.EditFormatString](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) has a non- <c>null</c>, non-empty value different from the default for the datatype.

Return type:System.Boolean
public abstract bool HasNonDefaultEditFormat { get; }
HideSurroundingHtml()

Gets a value indicating whether the “HiddenInput” display template should return

<c>string.Empty</c> (not the expression value) and whether the “HiddenInput” editor template should not also return the expression value (together with the hidden &lt;input&gt; element).

Return type:System.Boolean
public abstract bool HideSurroundingHtml { get; }
HtmlEncode()

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

Return type:System.Boolean
public abstract bool HtmlEncode { get; }
Identity()

Gets the key for the current instance.

Return type:Microsoft.AspNet.Mvc.ModelBinding.Metadata.ModelMetadataIdentity
protected ModelMetadataIdentity Identity { get; }
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; }
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; }
IsCollectionType()

Gets a value indicating whether or not [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) is a collection type.

Return type:System.Boolean
public bool IsCollectionType { get; }
IsComplexType()

Gets a value indicating whether [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) is a simple type.

Return type:System.Boolean
public bool IsComplexType { get; }
IsEnum()

Gets a value indicating whether [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) or <c>Nullable.GetUnderlyingType(ModelType)</c> is for an [System.Enum]().

Return type:System.Boolean
public abstract bool IsEnum { get; }
IsFlagsEnum()

Gets a value indicating whether [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) or <c>Nullable.GetUnderlyingType(ModelType)</c> is for an [System.Enum]() with an associated [System.FlagsAttribute]().

Return type:System.Boolean
public abstract bool IsFlagsEnum { get; }
IsNullableValueType()

Gets a value indicating whether or not [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.ModelType](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) is a [System.Nullable`1]().

Return type:System.Boolean
public bool IsNullableValueType { get; }
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; }
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; }
MetadataKind()

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

Return type:Microsoft.AspNet.Mvc.ModelBinding.Metadata.ModelMetadataKind
public ModelMetadataKind MetadataKind { get; }
ModelType()

Gets the model type represented by the current instance.

Return type:System.Type
public Type ModelType { get; }
NullDisplayText()

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

Return type:System.String
public abstract string NullDisplayText { get; }
Order()

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

Return type:System.Int32
public abstract int Order { get; }
Properties()

Gets the collection of [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata](Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.yml) instances for the model’s properties.

Return type:Microsoft.AspNet.Mvc.ModelBinding.ModelPropertyCollection
public abstract ModelPropertyCollection Properties { get; }
PropertyBindingPredicateProvider()

Gets the [Microsoft.AspNet.Mvc.ModelBinding.IPropertyBindingPredicateProvider](Microsoft.AspNet.Mvc.ModelBinding.IPropertyBindingPredicateProvider.yml), which can determine which properties should be model bound.

Return type:Microsoft.AspNet.Mvc.ModelBinding.IPropertyBindingPredicateProvider
public abstract IPropertyBindingPredicateProvider PropertyBindingPredicateProvider { get; }
PropertyGetter()

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

Return type:System.Func{System.Object,System.Object}
public abstract Func<object, object> PropertyGetter { get; }
PropertyName()

Gets the property name represented by the current instance.

Return type:System.String
public string PropertyName { get; }
PropertySetter()

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

Return type:System.Action{System.Object,System.Object}
public abstract Action<object, object> PropertySetter { get; }
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; }
ShowForEdit()

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

Return type:System.Boolean
public abstract bool ShowForEdit { get; }
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; }
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; }
ValidatorMetadata()

Gets a collection of metadata items for validators.

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

Methods

Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.GetDisplayName()

Gets a display name for the model.

Return type:System.String
Returns:The display name.
public string GetDisplayName()