ModelStateDictionary 类

定义

表示模型绑定状态。Represents the state of model binding.

public ref class ModelStateDictionary : System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<System::String ^, System::Web::ModelBinding::ModelState ^>>, System::Collections::Generic::IDictionary<System::String ^, System::Web::ModelBinding::ModelState ^>, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<System::String ^, System::Web::ModelBinding::ModelState ^>>
[System.Serializable]
public class ModelStateDictionary : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string,System.Web.ModelBinding.ModelState>>, System.Collections.Generic.IDictionary<string,System.Web.ModelBinding.ModelState>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,System.Web.ModelBinding.ModelState>>
type ModelStateDictionary = class
    interface IDictionary<string, ModelState>
    interface ICollection<KeyValuePair<string, ModelState>>
    interface seq<KeyValuePair<string, ModelState>>
    interface IEnumerable
Public Class ModelStateDictionary
Implements ICollection(Of KeyValuePair(Of String, ModelState)), IDictionary(Of String, ModelState), IEnumerable(Of KeyValuePair(Of String, ModelState))
继承
ModelStateDictionary
属性
实现

构造函数

ModelStateDictionary()

初始化 ModelStateDictionary 类的新实例。Initializes a new instance of the ModelStateDictionary class.

ModelStateDictionary(ModelStateDictionary)

使用现有字典集合初始化 ModelStateDictionary 类的新实例。Initializes a new instance of the ModelStateDictionary class using an existing dictionary collection.

属性

Count

获取集合中键/值对的数目。Gets the number of key/value pairs in the collection.

IsReadOnly

获取一个值,该值指示字典是否为只读。Gets a value that indicates whether the dictionary is read-only.

IsValid

获取指示字典中所有模型状态对象是否有任何错误的值。Gets a value that indicates whether there are any errors in any of the model state objects in the dictionary.

Item[String]

获取或设置与指定的键关联的值。Gets or sets the value that is associated with the specified key.

Keys

获取包含词典中的键的集合。Gets a collection that contains the keys of the dictionary.

Values

获取包含词典中的值的集合。Gets a collection that contains the values of the dictionary.

方法

Add(KeyValuePair<String,ModelState>)

将指定项添加到字典。Adds the specified item to the dictionary.

Add(String, ModelState)

将具有指定的键和值的项添加到字典中。Adds an item that has the specified key and value to the dictionary.

AddModelError(String, Exception)

使用指定的密钥和使用指定值异常,添加一个模型错误到错误集合。Adds a model error to the errors collection using the specified key and using the specified exception for the value.

AddModelError(String, String)

使用指定的密钥和使用指定值错误消息,添加指定的模型错误到错误集合。Adds the specified model error to the errors collection using the specified key and using the specified error message string for the value.

Clear()

从字典中移除所有项。Removes all items from the dictionary.

Contains(KeyValuePair<String,ModelState>)

确定模型状态字典是否包含特定项。Determines whether the model-state dictionary contains a specific item.

ContainsKey(String)

确定模型状态字典是否包含指定的键。Determines whether the model-state dictionary contains the specified key.

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

从指定的数组索引开始,将字典中的元素复制到一个数组中。Copies the elements of the dictionary to an array, starting at a specified index.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnumerator()

返回一个可用于循环访问字典的枚举器。Returns an enumerator that can be used to iterate through the dictionary.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsValidField(String)

确定是否存在与指定键关联或以指定键为前缀的任何 ModelError 对象。Determines whether there are any ModelError objects that are associated with the specified key or that are prefixed with the specified key.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Merge(ModelStateDictionary)

将指定的模型状态对象中的值复制到此字典中,如果键相同,则覆盖现有值。Copies the values from the specified model-state dictionary object into this dictionary, overwriting existing values if the keys are the same.

Remove(KeyValuePair<String,ModelState>)

从模型状态字典中移除指定项的第一个匹配项。Removes the first occurrence of the specified item from the model-state dictionary.

Remove(String)

从词典中移除具有指定键的项。Removes the item that has the specified key from the dictionary.

SetModelValue(String, ValueProviderResult)

设置指定的键的值。Sets the value for the specified key.

ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TryGetValue(String, ModelState)

尝试获取与指定的键关联的值。Attempts to gets the value that is associated with the specified key.

显式界面实现

IEnumerable.GetEnumerator()

返回一个可用于循环访问集合的枚举数。Returns an enumerator that can be used to iterate through the collection.

扩展方法

CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于