ViewDataDictionary Class

Namespace
Microsoft.AspNetCore.Mvc.ViewFeatures
Assemblies
  • Microsoft.AspNetCore.Mvc.ViewFeatures

Syntax

public class ViewDataDictionary : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary

Constructors

ViewDataDictionary(Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary)

Initializes a new instance of the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary class.

Arguments:
public ViewDataDictionary(IModelMetadataProvider metadataProvider, ModelStateDictionary modelState)
ViewDataDictionary(Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider, Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary, System.Type)

Initializes a new instance of the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary class.

Arguments:
protected ViewDataDictionary(IModelMetadataProvider metadataProvider, ModelStateDictionary modelState, Type declaredModelType)
ViewDataDictionary(Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider, System.Type)

Initializes a new instance of the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary class.

Arguments:
protected ViewDataDictionary(IModelMetadataProvider metadataProvider, Type declaredModelType)
ViewDataDictionary(Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary)

Initializes a new instance of the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary class based entirely on an existing instance.

Arguments:source (Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary) – Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary instance to copy initial values from.
public ViewDataDictionary(ViewDataDictionary source)
ViewDataDictionary(Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary, System.Object, System.Type)

Initializes a new instance of the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary class based in part on an existing instance. This constructor is careful to avoid exceptions Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.SetModel(System.Object) may throw when <em>model</em> is <code>null</code>.

Arguments:
protected ViewDataDictionary(ViewDataDictionary source, object model, Type declaredModelType)
ViewDataDictionary(Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary, System.Type)

Initializes a new instance of the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary class based in part on an existing instance.

Arguments:
protected ViewDataDictionary(ViewDataDictionary source, Type declaredModelType)

Methods

Add(System.Collections.Generic.KeyValuePair<System.String, System.Object>)
public void Add(KeyValuePair<string, object> item)
Add(System.String, System.Object)
public void Add(string key, object value)
Clear()
public void Clear()
Contains(System.Collections.Generic.KeyValuePair<System.String, System.Object>)
Return type:System.Boolean
public bool Contains(KeyValuePair<string, object> item)
ContainsKey(System.String)
Return type:System.Boolean
public bool ContainsKey(string key)
CopyTo(System.Collections.Generic.KeyValuePair<System.String, System.Object>[], System.Int32)
public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
Eval(System.String)

Gets value of named <em>expression</em> in this Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.

Arguments:expression (System.String) – Expression name, relative to the current model.
Return type:System.Object
Returns:Value of named <em>expression</em> in this Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.
public object Eval(string expression)
Eval(System.String, System.String)

Gets value of named <em>expression</em> in this Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary, formatted using given <em>format</em>.

Arguments:
Return type:

System.String

Returns:

Value of named <em>expression</em> in this Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary, formatted using given <em>format</em>.

public string Eval(string expression, string format)
FormatValue(System.Object, System.String)

Formats the given <em>value</em> using given <em>format</em>.

Arguments:
Return type:

System.String

Returns:

The formatted System.String.

public static string FormatValue(object value, string format)
GetViewDataInfo(System.String)

Gets Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataInfo for named <em>expression</em> in this Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.

Arguments:expression (System.String) – Expression name, relative to the current model.
Return type:Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataInfo
Returns:Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataInfo for named <em>expression</em> in this Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.
public ViewDataInfo GetViewDataInfo(string expression)
Remove(System.Collections.Generic.KeyValuePair<System.String, System.Object>)
Return type:System.Boolean
public bool Remove(KeyValuePair<string, object> item)
Remove(System.String)
Return type:System.Boolean
public bool Remove(string key)
SetModel(System.Object)

Set Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.ModelExplorer to ensure Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Model and Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer.Model reflect the new <em>value</em>.

Arguments:value (System.Object) – New Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Model value.
protected virtual void SetModel(object value)
GetEnumerator()
Return type:System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String>>
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
GetEnumerator()
Return type:System.Collections.IEnumerator
IEnumerator IEnumerable.GetEnumerator()
TryGetValue(System.String, out System.Object)
Return type:System.Boolean
public bool TryGetValue(string key, out object value)

Properties

Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Count
Return type:System.Int32
public int Count { get; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.IsReadOnly
Return type:System.Boolean
public bool IsReadOnly { get; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Item[System.String]
Return type:System.Object
public object this[string index] { get; set; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Keys
Return type:System.Collections.Generic.ICollection<System.String>
public ICollection<string> Keys { get; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Model

Gets or sets the current model.

Return type:System.Object
public object Model { get; set; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.ModelExplorer

Gets or sets the Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer for the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Model.

Return type:Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer
public ModelExplorer ModelExplorer { get; set; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.ModelMetadata

Gets the Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata for an expression, the Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Model (if non-<code>null</code>), or the declared System.Type.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata
public ModelMetadata ModelMetadata { get; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.ModelState

Gets the Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary.

Return type:Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary
public ModelStateDictionary ModelState { get; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.TemplateInfo

Gets the Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateInfo.

Return type:Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateInfo
public TemplateInfo TemplateInfo { get; }
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Values
Return type:System.Collections.Generic.ICollection<System.Object>
public ICollection<object> Values { get; }