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. |
info | |
System. |
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. |
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.
Declaration
public object this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System. |
key |
Property Value
Type | Description |
---|---|
System. |
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. |
Target
The target object that the Property
Declaration
public object Target { get; }
Property Value
Type | Description |
---|---|
System. |
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. |
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. |
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. |
key | The object to use as the key of the element to add. |
System. |
value | The object to use as the value of the element to add. |
Exceptions
Type | Condition |
---|---|
System. |
|
System. |
An element with the same key already exists in the System.Collections.Generic.IDictionary<, >. |
System. |
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. |
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. |
item | The object to locate in the System.Collections.Generic.ICollection<>. |
Returns
Type | Description |
---|---|
System. |
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. |
key | The key to locate in the System.Collections.Generic.IDictionary<, >. |
Returns
Type | Description |
---|---|
System. |
true if the System.Collections.Generic.IDictionary<, > contains an element with the key; otherwise, false. |
Exceptions
Type | Condition |
---|---|
System. |
|
GenerateTypeBag()
Generate a collection of System.
Declaration
public IDictionary<string, Type> GenerateTypeBag()
Returns
Type | Description |
---|---|
System. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
Type | Description |
---|---|
System. |
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. |
info | |
System. |
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. |
key | The key of the element to remove. |
Returns
Type | Description |
---|---|
System. |
true if the element is successfully removed; otherwise, false. This method also returns false if |
Exceptions
Type | Condition |
---|---|
System. |
|
System. |
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. |
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 |
Returns
Type | Description |
---|---|
System. |
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. |
key | The key whose value to get. |
System. |
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. |
true if the object that implements System.Collections.Generic.IDictionary<, > contains an element with the specified key; otherwise, false. |
Exceptions
Type | Condition |
---|---|
System. |
|