Class PropertyBag
A class used to save and load a collection a name/value pairs
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Data.Dynamic
Assembly: EPiServer.Data.dll
Version: 7.19.2Syntax
public class PropertyBag : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, ISerializable, IDynamicDataConstructors
PropertyBag()
Declaration
public PropertyBag()PropertyBag(SerializationInfo, StreamingContext)
Declaration
protected PropertyBag(SerializationInfo info, StreamingContext context)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Runtime.Serialization.SerializationInfo | info | |
| System.Runtime.Serialization.StreamingContext | context | 
Properties
Count
Gets the number of elements contained in the System.Collections.Generic.ICollection<T>.
Declaration
public int Count { get; }Property Value
| Type | Description | 
|---|---|
| System.Int32 | 
Id
Declaration
public Identity Id { get; set; }Property Value
| Type | Description | 
|---|---|
| Identity | 
Item[String]
Gets or sets the System.Object with the specified key.
Declaration
public object this[string key] { get; set; }Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | key | 
Property Value
| Type | Description | 
|---|---|
| System.Object | 
Keys
Gets an System.Collections.Generic.ICollection<T> containing the keys of the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public ICollection<string> Keys { get; }Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.ICollection<System.String> | 
Target
The target object that the PropertyBag is derived from
Declaration
public object Target { get; }Property Value
| Type | Description | 
|---|---|
| System.Object | 
Values
Gets an System.Collections.Generic.ICollection<T> containing the values in the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public ICollection<object> Values { get; }Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.ICollection<System.Object> | 
Methods
Add(IDictionary<String, Object>)
Adds the values in properties to the current object
Declaration
public void Add(IDictionary<string, object> properties)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IDictionary<System.String, System.Object> | properties | The name/value collection to add | 
Add(String, Object)
Adds an element with the provided key and value to the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public void Add(string key, object value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | key | The object to use as the key of the element to add. | 
| System.Object | value | The object to use as the value of the element to add. | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
| System.ArgumentException | An element with the same key already exists in the System.Collections.Generic.IDictionary<TKey, TValue>. | 
| System.NotSupportedException | The System.Collections.Generic.IDictionary<TKey, TValue> is read-only. | 
Clear()
Removes all items from the System.Collections.Generic.ICollection<T>.
Declaration
public void Clear()Exceptions
| Type | Condition | 
|---|---|
| System.NotSupportedException | The System.Collections.Generic.ICollection<T> is read-only. | 
Contains(KeyValuePair<String, Object>)
Determines whether the System.Collections.Generic.ICollection<T> contains a specific value.
Declaration
public bool Contains(KeyValuePair<string, object> item)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | The object to locate in the System.Collections.Generic.ICollection<T>. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if  | 
ContainsKey(String)
Determines whether the System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the specified key.
Declaration
public bool ContainsKey(string key)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | key | The key to locate in the System.Collections.Generic.IDictionary<TKey, TValue>. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the key; otherwise, false. | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
GenerateTypeBag()
Generate a collection of System.String to System.Type from the properties held in the current object
Declaration
public IDictionary<string, Type> GenerateTypeBag()Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IDictionary<System.String, System.Type> | 
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, System.Object>> | A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. | 
GetObjectData(SerializationInfo, StreamingContext)
Declaration
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Runtime.Serialization.SerializationInfo | info | |
| System.Runtime.Serialization.StreamingContext | context | 
Remove(String)
Removes the element with the specified key from the System.Collections.Generic.IDictionary<TKey, TValue>.
Declaration
public bool Remove(string key)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | key | The key of the element to remove. | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the element is successfully removed; otherwise, false.  This method also returns false if  | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
| System.NotSupportedException | The System.Collections.Generic.IDictionary<TKey, TValue> is read-only. | 
ToObject(Object)
Populate value properties with those held in the current object
Declaration
public void ToObject(object value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | value | 
ToObject(Type)
Create an instance of type and populate its properties with those held in the current object
Declaration
public object ToObject(Type type)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | type | 
Returns
| Type | Description | 
|---|---|
| System.Object | 
ToObject<T>()
Create an instance of T and populate its properties with those held in the current object
Declaration
public T ToObject<T>()Returns
| Type | Description | 
|---|---|
| T | 
Type Parameters
| Name | Description | 
|---|---|
| T | 
TryGetValue(String, out Object)
Gets the value associated with the specified key.
Declaration
public bool TryGetValue(string key, out object value)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | key | The key whose value to get. | 
| System.Object | value | When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the  | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | true if the object that implements System.Collections.Generic.IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false. | 
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | 
 | 
Explicit Interface Implementations
ICollection<KeyValuePair<String, Object>>.Add(KeyValuePair<String, Object>)
Declaration
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | 
ICollection<KeyValuePair<String, Object>>.CopyTo(KeyValuePair<String, Object>[], Int32)
Declaration
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.KeyValuePair<System.String, System.Object>[] | array | |
| System.Int32 | arrayIndex | 
ICollection<KeyValuePair<String, Object>>.IsReadOnly
Declaration
bool ICollection<KeyValuePair<string, object>>.IsReadOnly { get; }Returns
| Type | Description | 
|---|---|
| System.Boolean | 
ICollection<KeyValuePair<String, Object>>.Remove(KeyValuePair<String, Object>)
Declaration
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.KeyValuePair<System.String, System.Object> | item | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()Returns
| Type | Description | 
|---|---|
| System.Collections.IEnumerator | An System.Collections.IEnumerator object that can be used to iterate through the collection. | 
