Class PropertyBag
A class used to save and load a collection a name/value pairs
Inheritance
Implements
Namespace: EPiServer.Data.Dynamic
Assembly: EPiServer.Data.dll
Version: 12.0.3Syntax
public class PropertyBag : Object, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, ISerializable, IDynamicData
Constructors
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<>.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Id
The DDS identifier for the property bag
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<> containing the keys of the System.Collections.Generic.IDictionary<, >.
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<> containing the values in the System.Collections.Generic.IDictionary<, >.
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<, >.
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<, >. |
System.NotSupportedException | The System.Collections.Generic.IDictionary<, > is read-only. |
Clear()
Removes all items from the System.Collections.Generic.ICollection<>.
Declaration
public void Clear()
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | The System.Collections.Generic.ICollection<> is read-only. |
Contains(KeyValuePair<String, Object>)
Determines whether the System.Collections.Generic.ICollection<> 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<>. |
Returns
Type | Description |
---|---|
System.Boolean | true if |
ContainsKey(String)
Determines whether the System.Collections.Generic.IDictionary<, > 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<, >. |
Returns
Type | Description |
---|---|
System.Boolean | true if the System.Collections.Generic.IDictionary<, > 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<> 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<, >.
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<, > 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<, > contains an element with the specified key; otherwise, false. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|