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
keyType
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
itemKeyValuePair<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
keyTypeThe key of the element to add.
valueIModelBinderThe value of the element to add.
Exceptions
- NotSupportedException
The IDictionary<TKey, TValue> object is read-only.
- ArgumentNullException
keyis 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
itemKeyValuePair<Type, IModelBinder>The object to locate in the ICollection<T> object.
Returns
- bool
true if
itemis 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
keyTypeThe 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
keyis 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
arrayKeyValuePair<Type, IModelBinder>[]The one-dimensional array that is the destination of the elements copied from ICollection<T>. The array must have zero-based indexing.
arrayIndexintThe zero-based index in
arrayat which copying starts.
Exceptions
- ArgumentNullException
arrayis null.- ArgumentOutOfRangeException
arrayIndexis less than 0.- ArgumentException
arrayis multidimensional.-or-arrayIndexis 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 fromarrayIndexto the end of the destination array. -or- TypeTcannot 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
modelTypeTypeThe type of the model to retrieve.
Returns
- IModelBinder
The model binder.
Exceptions
- ArgumentNullException
The
modelTypeparameter 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
modelTypeTypeThe type of the model to retrieve.
fallbackToDefaultbooltrue to retrieve the default model binder.
Returns
- IModelBinder
The model binder.
Exceptions
- ArgumentNullException
The
modelTypeparameter 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
itemKeyValuePair<Type, IModelBinder>The object to remove from the ICollection<T> object.
Returns
- bool
true if
itemwas successfully removed from the model binder dictionary; otherwise, false. This method also returns false ifitemis 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
keyTypeThe key of the element to remove.
Returns
- bool
true if the element is successfully removed; otherwise, false. This method also returns false if
keywas not found in the model binder dictionary.
Exceptions
- NotSupportedException
The IDictionary<TKey, TValue> object is read-only.
- ArgumentNullException
keyis null.
TryGetValue(Type, out IModelBinder)
Gets the value that is associated with the specified key.
public bool TryGetValue(Type key, out IModelBinder value)
Parameters
keyTypeThe key of the value to get.
valueIModelBinderWhen this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the
valueparameter. 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
keyis null.