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: 11.20.7Syntax
public class PropertyBag : 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<T>.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System. |
Id
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<T> containing the keys of the System.Collections.Generic.IDictionary<TKey, TValue>.
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<T> containing the values in the System.Collections.Generic.IDictionary<TKey, TValue>.
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<TKey, TValue>.
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<TKey, TValue>. |
System. |
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. |
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. |
item | The object to locate in the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System. |
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. |
key | The key to locate in the System.Collections.Generic.IDictionary<TKey, TValue>. |
Returns
Type | Description |
---|---|
System. |
true if the System.Collections.Generic.IDictionary<TKey, TValue> 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<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. |
info | |
System. |
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. |
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<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. |
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<TKey, TValue> contains an element with the specified key; otherwise, false. |
Exceptions
Type | Condition |
---|---|
System. |
|
Explicit Interface Implementations
ICollection<KeyValuePair<String, Object>>.Add(KeyValuePair<String, Object>)
Adds an item to the System.Collections.Generic.ICollection<T>.
Declaration
void ICollection<KeyValuePair<string, object>>.Add(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System. |
item | The object to add to the System.Collections.Generic.ICollection<T>. |
Exceptions
Type | Condition |
---|---|
System. |
The System.Collections.Generic.ICollection<T> is read-only. |
ICollection<KeyValuePair<String, Object>>.CopyTo(KeyValuePair<String, Object>[], Int32)
Copies the elements of the System.Collections.Generic.ICollection<T> to an System.
Declaration
void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
System. |
array | The one-dimensional System. |
System. |
arrayIndex | The zero-based index in |
ICollection<KeyValuePair<String, Object>>.IsReadOnly
Gets a value indicating whether the System.Collections.Generic.ICollection<T> is read-only.
Declaration
bool ICollection<KeyValuePair<string, object>>.IsReadOnly { get; }
Returns
Type | Description |
---|---|
System. |
ICollection<KeyValuePair<String, Object>>.Remove(KeyValuePair<String, Object>)
Removes the first occurrence of a specific object from the System.Collections.Generic.ICollection<T>.
Declaration
bool ICollection<KeyValuePair<string, object>>.Remove(KeyValuePair<string, object> item)
Parameters
Type | Name | Description |
---|---|---|
System. |
item | The object to remove from the System.Collections.Generic.ICollection<T>. |
Returns
Type | Description |
---|---|
System. |
true if |
Exceptions
Type | Condition |
---|---|
System. |
The System.Collections.Generic.ICollection<T> is read-only. |
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System. |
An System. |