ModelStateDictionary Class

 

Represents the state of an attempt to bind a posted form to an action method, which includes validation information.

Namespace:   System.Web.Http.ModelBinding
Assembly:  System.Web.Http (in System.Web.Http.dll)

Inheritance Hierarchy

System.Object
  System.Web.Http.ModelBinding.ModelStateDictionary

Syntax

[SerializableAttribute]
[DefaultMemberAttribute("Item")]
public class ModelStateDictionary : IDictionary<string, ModelState>, 
    ICollection<KeyValuePair<string, ModelState>>, IEnumerable<KeyValuePair<string, ModelState>>, 
    IEnumerable
[SerializableAttribute]
[DefaultMemberAttribute("Item")]
public ref class ModelStateDictionary : IDictionary<String^, ModelState^>, 
    ICollection<KeyValuePair<String^, ModelState^>>, IEnumerable<KeyValuePair<String^, ModelState^>>, 
    IEnumerable
[<SerializableAttribute>]
[<DefaultMemberAttribute("Item")>]
type ModelStateDictionary = 
    class
        interface IDictionary<string, ModelState>
        interface ICollection<KeyValuePair<string, ModelState>>
        interface IEnumerable<KeyValuePair<string, ModelState>>
        interface IEnumerable
    end
<SerializableAttribute>
<DefaultMemberAttribute("Item")>
Public Class ModelStateDictionary
    Implements IDictionary(Of String, ModelState), ICollection(Of KeyValuePair(Of String, ModelState)),
    IEnumerable(Of KeyValuePair(Of String, ModelState)), IEnumerable

Constructors

Name Description
System_CAPS_pubmethod ModelStateDictionary()

Initializes a new instance of the ModelStateDictionary class.

System_CAPS_pubmethod ModelStateDictionary(ModelStateDictionary)

Initializes a new instance of the ModelStateDictionary class by using values that are copied from the specified model-state dictionary.

Properties

Name Description
System_CAPS_pubproperty Count

Gets the number of key/value pairs in the collection.

System_CAPS_pubproperty IsReadOnly

Gets a value that indicates whether the collection is read-only.

System_CAPS_pubproperty IsValid

Gets a value that indicates whether this instance of the model-state dictionary is valid.

System_CAPS_pubproperty Item[String]

Gets or sets the value that is associated with the specified key.

System_CAPS_pubproperty Keys

Gets a collection that contains the keys in the dictionary.

System_CAPS_pubproperty Values

Gets a collection that contains the values in the dictionary.

Methods

Name Description
System_CAPS_pubmethod Add(KeyValuePair<String, ModelState>)

Adds the specified item to the model-state dictionary.

System_CAPS_pubmethod Add(String, ModelState)

Adds an element that has the specified key and value to the model-state dictionary.

System_CAPS_pubmethod AddModelError(String, Exception)

Adds the specified model error to the errors collection for the model-state dictionary that is associated with the specified key.

System_CAPS_pubmethod AddModelError(String, String)

Adds the specified error message to the errors collection for the model-state dictionary that is associated with the specified key.

System_CAPS_pubmethod Clear()

Removes all items from the model-state dictionary.

System_CAPS_pubmethod Contains(KeyValuePair<String, ModelState>)

Determines whether the model-state dictionary contains a specific value.

System_CAPS_pubmethod ContainsKey(String)

Determines whether the model-state dictionary contains the specified key.

System_CAPS_pubmethod CopyTo(KeyValuePair<String, ModelState>[], Int32)

Copies the elements of the model-state dictionary to an array, starting at a specified index.

System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethod GetEnumerator()

Returns an enumerator that can be used to iterate through the collection.

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_pubmethod IsValidField(String)

Determines whether there are any ModelError objects that are associated with or prefixed with the specified key.

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod Merge(ModelStateDictionary)

Copies the values from the specified ModelStateDictionary object into this dictionary, overwriting existing values if keys are the same.

System_CAPS_pubmethod Remove(KeyValuePair<String, ModelState>)

Removes the first occurrence of the specified object from the model-state dictionary.

System_CAPS_pubmethod Remove(String)

Removes the element that has the specified key from the model-state dictionary.

System_CAPS_pubmethod SetModelValue(String, ValueProviderResult)

Sets the value for the specified key by using the specified value provider dictionary.

System_CAPS_pubmethod ToString()

(Inherited from Object.)

System_CAPS_pubmethod TryGetValue(String, ModelState)

Attempts to gets the value that is associated with the specified key.

Explicit Interface Implementations

Name Description
System_CAPS_pubinterfaceSystem_CAPS_privmethod IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

System.Web.Http.ModelBinding Namespace

Return to top