ViewDataDictionary Class¶
Syntax¶
public class ViewDataDictionary : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
Constructors¶
-
ViewDataDictionary
(Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider, Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary)¶ Initializes a new instance of the [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) class.
Arguments: - metadataProvider (Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider) – [Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider]() instance used to calculate [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) values.
- modelState (Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary) – [Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary]() instance for this scope.
public ViewDataDictionary(IModelMetadataProvider metadataProvider, ModelStateDictionary modelState)
-
ViewDataDictionary
(Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider, Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary, System.Type) Initializes a new instance of the [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) class.
Arguments: - metadataProvider (Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider) – [Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider]() instance used to calculate [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) values.
- modelState (Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary) – [Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary]() instance for this scope.
- declaredModelType (System.Type) – [System.Type]() of [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) values expected. Used to set [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) when [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) is <c>null</c>.
protected ViewDataDictionary(IModelMetadataProvider metadataProvider, ModelStateDictionary modelState, Type declaredModelType)
-
ViewDataDictionary
(Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider, System.Type) Initializes a new instance of the [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) class.
Arguments: - metadataProvider (Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider) – [Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider]() instance used to calculate [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) values.
- declaredModelType (System.Type) – [System.Type]() of [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) values expected. Used to set [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) when [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) is <c>null</c>.
protected ViewDataDictionary(IModelMetadataProvider metadataProvider, Type declaredModelType)
-
ViewDataDictionary
(Microsoft.AspNet.Mvc.ViewDataDictionary) Initializes a new instance of the [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) class based entirely on an existing instance.
Arguments: - source (Microsoft.AspNet.Mvc.ViewDataDictionary) – [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) instance to copy initial values from.
public ViewDataDictionary(ViewDataDictionary source)
-
ViewDataDictionary
(Microsoft.AspNet.Mvc.ViewDataDictionary, System.Object) Initializes a new instance of the [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) class based in part on an existing instance. This constructor is careful to avoid exceptions [Microsoft.AspNet.Mvc.ViewDataDictionary.SetModel(System.Object)](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) may throw when
<paramref name=”model” /> is <c>null</c>.
Arguments: - source (Microsoft.AspNet.Mvc.ViewDataDictionary) – [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) instance to copy initial values from.
- model (System.Object) – Value for the [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) property.
public ViewDataDictionary(ViewDataDictionary source, object model)
-
ViewDataDictionary
(Microsoft.AspNet.Mvc.ViewDataDictionary, System.Object, System.Type) Initializes a new instance of the [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) class based in part on an existing instance. This constructor is careful to avoid exceptions [Microsoft.AspNet.Mvc.ViewDataDictionary.SetModel(System.Object)](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) may throw when
<paramref name=”model” /> is <c>null</c>.
Arguments: - source (Microsoft.AspNet.Mvc.ViewDataDictionary) – [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) instance to copy initial values from.
- model (System.Object) – Value for the [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) property.
- declaredModelType (System.Type) – [System.Type]() of [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) values expected. Used to set [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) when [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) is <c>null</c>.
protected ViewDataDictionary(ViewDataDictionary source, object model, Type declaredModelType)
-
ViewDataDictionary
(Microsoft.AspNet.Mvc.ViewDataDictionary, System.Type) Initializes a new instance of the [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) class based in part on an existing instance.
Arguments: - source (Microsoft.AspNet.Mvc.ViewDataDictionary) – [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) instance to copy initial values from.
- declaredModelType (System.Type) – [System.Type]() of [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) values expected. Used to set [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) when [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) is <c>null</c>.
protected ViewDataDictionary(ViewDataDictionary source, Type declaredModelType)
-
Properties¶
-
Count
()¶ Return type: System.Int32 public int Count { get; }
-
IsReadOnly
()¶ Return type: System.Boolean public bool IsReadOnly { get; }
-
Microsoft.AspNet.Mvc.ViewDataDictionary.Item[System.String]
Return type: System.Object public object this[string index] { get; set; }
-
Keys
()¶ Return type: System.Collections.Generic.ICollection{System.String} public ICollection<string> Keys { get; }
-
Model
()¶ Return type: System.Object public object Model { get; set; }
-
ModelExplorer
()¶ Gets or sets the [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelExplorer](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) for the [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml).
Return type: Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer public ModelExplorer ModelExplorer { get; set; }
-
ModelMetadata
()¶ [Microsoft.AspNet.Mvc.ViewDataDictionary.ModelMetadata](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) for the current [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) value or the declared [System.Type]() if [Microsoft.AspNet.Mvc.ViewDataDictionary.Model](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) is <c>null</c>.
Return type: Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata public ModelMetadata ModelMetadata { get; }
-
ModelState
()¶ Return type: Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary public ModelStateDictionary ModelState { get; }
-
TemplateInfo
()¶ Return type: Microsoft.AspNet.Mvc.TemplateInfo public TemplateInfo TemplateInfo { get; }
-
Values
()¶ Return type: System.Collections.Generic.ICollection{System.Object} public ICollection<object> Values { get; }
-
Methods¶
-
Add
(System.Collections.Generic.KeyValuePair<System.String, System.Object>)¶ Arguments: - item (System.Collections.Generic.KeyValuePair{System.String,System.Object}) –
public void Add(KeyValuePair<string, object> item)
-
Add
(System.String, System.Object) Arguments: - key (System.String) –
- value (System.Object) –
public void Add(string key, object value)
-
Microsoft.AspNet.Mvc.ViewDataDictionary.Clear()
public void Clear()
-
Contains
(System.Collections.Generic.KeyValuePair<System.String, System.Object>)¶ Arguments: - item (System.Collections.Generic.KeyValuePair{System.String,System.Object}) –
Return type: System.Boolean
public bool Contains(KeyValuePair<string, object> item)
-
ContainsKey
(System.String)¶ Arguments: - key (System.String) –
Return type: System.Boolean
public bool ContainsKey(string key)
-
CopyTo
(System.Collections.Generic.KeyValuePair<System.String, System.Object>[], System.Int32)¶ Arguments: - array (System.Collections.Generic.KeyValuePair{System.String,System.Object}[]) –
- arrayIndex (System.Int32) –
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
-
Eval
(System.String)¶ Gets value of named <paramref name=”expression” /> in this [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml).
Arguments: - expression (System.String) – Expression name, relative to the current model.
Return type: System.Object
Returns: Value of named <paramref name=”expression” /> in this [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml).
public object Eval(string expression)
-
Eval
(System.String, System.String) Gets value of named <paramref name=”expression” /> in this [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml), formatted using given <paramref name=”format” />.
Arguments: - expression (System.String) – Expression name, relative to the current model.
- format (System.String) – The composite format [System.String]() (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
Return type: System.String
Returns: Value of named <paramref name=”expression” /> in this [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml), formatted using given <paramref name=”format” />.
public string Eval(string expression, string format)
-
FormatValue
(System.Object, System.String)¶ Arguments: - value (System.Object) –
- format (System.String) –
Return type: System.String
public static string FormatValue(object value, string format)
-
GetViewDataInfo
(System.String)¶ Gets [Microsoft.AspNet.Mvc.Rendering.Expressions.ViewDataInfo](Microsoft.AspNet.Mvc.Rendering.Expressions.ViewDataInfo.yml) for named <paramref name=”expression” /> in this [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml).
Arguments: - expression (System.String) – Expression name, relative to the current model.
Return type: Microsoft.AspNet.Mvc.Rendering.Expressions.ViewDataInfo
Returns: [Microsoft.AspNet.Mvc.Rendering.Expressions.ViewDataInfo](Microsoft.AspNet.Mvc.Rendering.Expressions.ViewDataInfo.yml) for named <paramref name=”expression” /> in this [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml).
public ViewDataInfo GetViewDataInfo(string expression)
-
Remove
(System.Collections.Generic.KeyValuePair<System.String, System.Object>)¶ Arguments: - item (System.Collections.Generic.KeyValuePair{System.String,System.Object}) –
Return type: System.Boolean
public bool Remove(KeyValuePair<string, object> item)
-
Remove
(System.String) Arguments: - key (System.String) –
Return type: System.Boolean
public bool Remove(string key)
-
SetModel
(System.Object)¶ Arguments: - value (System.Object) –
protected virtual void SetModel(object value)
-
Microsoft.AspNet.Mvc.ViewDataDictionary.System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String, System.Object>>.GetEnumerator()
Return type: System.Collections.Generic.IEnumerator{System.Collections.Generic.KeyValuePair{System.String,System.Object}} IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
-
Microsoft.AspNet.Mvc.ViewDataDictionary.System.Collections.IEnumerable.GetEnumerator()
Return type: System.Collections.IEnumerator IEnumerator IEnumerable.GetEnumerator()
-
TryGetValue
(System.String, out System.Object)¶ Arguments: - key (System.String) –
- value (System.Object) –
Return type: System.Boolean
public bool TryGetValue(string key, out object value)
-