Class ModelBinderDictionary
Represents a class that contains all model binders for the application, listed by binder type.
public class ModelBinderDictionary : IDictionary<Type, IModelBinder>, ICollection<KeyValuePair<Type, IModelBinder>>, IEnumerable<KeyValuePair<Type, IModelBinder>>, IEnumerable
- Inheritance
-
ModelBinderDictionary
- Implements
- Inherited Members
Constructors
ModelBinderDictionary()
Initializes a new instance of the ModelBinderDictionary class.
public ModelBinderDictionary()
Properties
Count
Gets the number of elements in the model binder dictionary.
public int Count { get; }
Property Value
- int
The number of elements in the model binder dictionary.
DefaultBinder
Gets or sets the default model binder.
public IModelBinder DefaultBinder { get; set; }
Property Value
- IModelBinder
The default model binder.
IsReadOnly
Gets a value that indicates whether the model binder dictionary is read-only.
public bool IsReadOnly { get; }
Property Value
- bool
true if the model binder dictionary is read-only; otherwise, false.
this[Type]
Gets or sets the specified key in an object that implements the IModelBinder interface.
public IModelBinder this[Type key] { get; set; }
Parameters
key
Type
Property Value
- IModelBinder
The key for the specified item.
Keys
Gets a collection that contains the keys in the model binder dictionary.
public ICollection<Type> Keys { get; }
Property Value
- ICollection<Type>
A collection that contains the keys in the model binder dictionary.
Values
Gets a collection that contains the values in the model binder dictionary.
public ICollection<IModelBinder> Values { get; }
Property Value
- ICollection<IModelBinder>
A collection that contains the values in the model binder dictionary.
Methods
Add(KeyValuePair<Type, IModelBinder>)
Adds the specified item to the model binder dictionary.
public void Add(KeyValuePair<Type, IModelBinder> item)
Parameters
item
KeyValuePair<Type, IModelBinder>The object to add to the ICollection<T> instance.
Exceptions
- NotSupportedException
The ICollection<T> object is read-only.
Add(Type, IModelBinder)
Adds the specified item to the model binder dictionary using the specified key.
public void Add(Type key, IModelBinder value)
Parameters
key
TypeThe key of the element to add.
value
IModelBinderThe value of the element to add.
Exceptions
- NotSupportedException
The IDictionary<TKey, TValue> object is read-only.
- ArgumentNullException
key
is null.- ArgumentException
An element that has the same key already exists in the IDictionary<TKey, TValue> object.
Clear()
Removes all items from the model binder dictionary.
public void Clear()
Exceptions
- NotSupportedException
The ICollection<T> object is read-only.
Contains(KeyValuePair<Type, IModelBinder>)
Determines whether the model binder dictionary contains a specified value.
public bool Contains(KeyValuePair<Type, IModelBinder> item)
Parameters
item
KeyValuePair<Type, IModelBinder>The object to locate in the ICollection<T> object.
Returns
- bool
true if
item
is found in the model binder dictionary; otherwise, false.
ContainsKey(Type)
Determines whether the model binder dictionary contains an element that has the specified key.
public bool ContainsKey(Type key)
Parameters
key
TypeThe key to locate in the IDictionary<TKey, TValue> object.
Returns
- bool
true if the model binder dictionary contains an element that has the specified key; otherwise, false.
Exceptions
- ArgumentNullException
key
is null.
CopyTo(KeyValuePair<Type, IModelBinder>[], int)
Copies the elements of the model binder dictionary to an array, starting at a specified index.
public void CopyTo(KeyValuePair<Type, IModelBinder>[] array, int arrayIndex)
Parameters
array
KeyValuePair<Type, IModelBinder>[]The one-dimensional array that is the destination of the elements copied from ICollection<T>. The array must have zero-based indexing.
arrayIndex
intThe zero-based index in
array
at which copying starts.
Exceptions
- ArgumentNullException
array
is null.- ArgumentOutOfRangeException
arrayIndex
is less than 0.- ArgumentException
array
is multidimensional.-or-arrayIndex
is equal to or greater than the length ofarray
.-or- The number of elements in the source ICollection<T> object is greater than the available space fromarrayIndex
to the end of the destination array. -or- TypeT
cannot be cast automatically to the type of the destination array.
GetBinder(Type)
Retrieves the model binder for the specified type.
public IModelBinder GetBinder(Type modelType)
Parameters
modelType
TypeThe type of the model to retrieve.
Returns
- IModelBinder
The model binder.
Exceptions
- ArgumentNullException
The
modelType
parameter is null.
GetBinder(Type, bool)
Retrieves the model binder for the specified type or retrieves the default model binder.
public virtual IModelBinder GetBinder(Type modelType, bool fallbackToDefault)
Parameters
modelType
TypeThe type of the model to retrieve.
fallbackToDefault
booltrue to retrieve the default model binder.
Returns
- IModelBinder
The model binder.
Exceptions
- ArgumentNullException
The
modelType
parameter is null.
GetEnumerator()
Returns an enumerator that can be used to iterate through the collection.
public IEnumerator<KeyValuePair<Type, IModelBinder>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<Type, IModelBinder>>
An enumerator that can be used to iterate through the collection.
Remove(KeyValuePair<Type, IModelBinder>)
Removes the first occurrence of the specified element from the model binder dictionary.
public bool Remove(KeyValuePair<Type, IModelBinder> item)
Parameters
item
KeyValuePair<Type, IModelBinder>The object to remove from the ICollection<T> object.
Returns
- bool
true if
item
was successfully removed from the model binder dictionary; otherwise, false. This method also returns false ifitem
is not found in the model binder dictionary.
Exceptions
- NotSupportedException
The ICollection<T> object is read-only.
Remove(Type)
Removes the element that has the specified key from the model binder dictionary.
public bool Remove(Type key)
Parameters
key
TypeThe key of the element to remove.
Returns
- bool
true if the element is successfully removed; otherwise, false. This method also returns false if
key
was not found in the model binder dictionary.
Exceptions
- NotSupportedException
The IDictionary<TKey, TValue> object is read-only.
- ArgumentNullException
key
is null.
TryGetValue(Type, out IModelBinder)
Gets the value that is associated with the specified key.
public bool TryGetValue(Type key, out IModelBinder value)
Parameters
key
TypeThe key of the value to get.
value
IModelBinderWhen this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the
value
parameter. This parameter is passed uninitialized.
Returns
- bool
true if the object that implements IDictionary<TKey, TValue> contains an element that has the specified key; otherwise, false.
Exceptions
- ArgumentNullException
key
is null.