Class TempDataDictionary
Represents a set of data that persists only from one request to the next.
public class TempDataDictionary : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
- Inheritance
-
TempDataDictionary
- Implements
- Inherited Members
Constructors
TempDataDictionary()
Initializes a new instance of the TempDataDictionary class.
public TempDataDictionary()
Properties
Count
Gets the number of elements in the ICollection<T> object.
public int Count { get; }
Property Value
- int
The number of elements in the ICollection<T> object.
this[string]
Gets or sets the object that has the specified key.
public object this[string key] { get; set; }
Parameters
keystring
Property Value
- object
The object that has the specified key.
Keys
Gets an ICollection<T> object that contains the keys of elements in the IDictionary<TKey, TValue> object.
public ICollection<string> Keys { get; }
Property Value
- ICollection<string>
The keys of the elements in the IDictionary<TKey, TValue> object.
Values
Gets the ICollection<T> object that contains the values in the IDictionary<TKey, TValue> object.
public ICollection<object> Values { get; }
Property Value
- ICollection<object>
The values of the elements in the object that implements IDictionary<TKey, TValue>.
Methods
Add(string, object)
Adds an element that has the specified key and value to the IDictionary<TKey, TValue> object.
public void Add(string key, object value)
Parameters
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 ICollection<T> instance.
public void Clear()
Exceptions
- NotSupportedException
The ICollection<T> object is read-only.
ContainsKey(string)
Determines whether the IDictionary<TKey, TValue> instance contains an element that has the specified key.
public bool ContainsKey(string key)
Parameters
keystringThe key to locate in the IDictionary<TKey, TValue> instance.
Returns
- bool
true if the IDictionary<TKey, TValue> instance contains an element that has the specified key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.
ContainsValue(object)
Determines whether the dictionary contains the specified value.
public bool ContainsValue(object value)
Parameters
valueobjectThe value.
Returns
- bool
true if the dictionary contains the specified value; otherwise, false.
GetEnumerator()
Gets the enumerator.
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, object>>
The enumerator.
Keep()
Marks all keys in the dictionary for retention.
public void Keep()
Keep(string)
Marks the specified key in the dictionary for retention.
public void Keep(string key)
Parameters
keystringThe key to retain in the dictionary.
Load(ControllerContext, ITempDataProvider)
Loads the specified controller context by using the specified data provider.
public void Load(ControllerContext controllerContext, ITempDataProvider tempDataProvider)
Parameters
controllerContextControllerContextThe controller context.
tempDataProviderITempDataProviderThe temporary data provider.
Peek(string)
Returns an object that contains the element that is associated with the specified key, without marking the key for deletion.
public object Peek(string key)
Parameters
keystringThe key of the element to return.
Returns
- object
An object that contains the element that is associated with the specified key.
Remove(string)
Removes the element that has the specified key from the IDictionary<TKey, TValue> object.
public bool Remove(string key)
Parameters
keystringThe key of the element to remove.
Returns
- bool
true if the element was removed successfully; otherwise, false. This method also returns false if
keywas not found in the IDictionary<TKey, TValue>. instance.
Exceptions
- NotSupportedException
The IDictionary<TKey, TValue> object is read-only.
- ArgumentNullException
keyis null.
Save(ControllerContext, ITempDataProvider)
Saves the specified controller context by using the specified data provider.
public void Save(ControllerContext controllerContext, ITempDataProvider tempDataProvider)
Parameters
controllerContextControllerContextThe controller context.
tempDataProviderITempDataProviderThe temporary data provider.
TryGetValue(string, out object)
Gets the value of the element that has the specified key.
public bool TryGetValue(string key, out object value)
Parameters
keystringThe key of the value to get.
valueobjectWhen this method returns, the value that is 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.