Try our conversational search powered by Generative AI!

Class PropertyDataCollection

Collection of PropertyData objects.

Inheritance
System.Object
PropertyDataCollection
Implements
System.Collections.Generic.ICollection<PropertyData>
System.Collections.Generic.IEnumerable<PropertyData>
System.Collections.IEnumerable
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
public class PropertyDataCollection : ICollection<PropertyData>, IEnumerable<PropertyData>, IEnumerable, IReadOnly<PropertyDataCollection>, IReadOnly
Remarks

Notes to inheritors If you override the indexers of this class, make sure that the Count property and Exists method match your implementation since they are used to indicate the boundaries of the collection.

Constructors

PropertyDataCollection()

Initializes a new instance of the PropertyDataCollection class.

Declaration
public PropertyDataCollection()

PropertyDataCollection(ICollection<RawProperty>)

Initializes a new instance of the PropertyDataCollection class.

Declaration
[Obsolete("No longer used, content are imported through IContentImporter and IPropertyImporter")]
public PropertyDataCollection(ICollection<RawProperty> properties)
Parameters
Type Name Description
System.Collections.Generic.ICollection<RawProperty> properties

The properties.

PropertyDataCollection(Int32)

Initializes a new instance of the PropertyDataCollection class.

Declaration
public PropertyDataCollection(int capacity)
Parameters
Type Name Description
System.Int32 capacity

The initial capacity of the collection.

Properties

Count

Gets the number of elements contained in the PropertyDataCollection.

Declaration
public virtual int Count { get; }
Property Value
Type Description
System.Int32

GetHandler

Gets or sets the handler for this property

Declaration
public static GetPropertyDelegate GetHandler { get; set; }
Property Value
Type Description
GetPropertyDelegate

IsDataInitialized

Gets or sets a value indicating whether InitializeData has been called for this instance.

Declaration
public bool IsDataInitialized { get; set; }
Property Value
Type Description
System.Boolean

true if this instance has been initialized; otherwise, false.

IsReadOnly

Gets or sets a value indicating whether the System.Collections.Specialized.NameObjectCollectionBase instance is read-only.

Declaration
public virtual bool IsReadOnly { get; protected set; }
Property Value
Type Description
System.Boolean

Item[Int32]

Gets or sets a property by index.

Declaration
public virtual PropertyData this[int index] { get; set; }
Parameters
Type Name Description
System.Int32 index
Property Value
Type Description
PropertyData
Remarks

When overridden in a derived class, make sure that the Count implementation is syncronized with the override of this method.

Item[String]

Gets or sets a property by name.

Declaration
public virtual PropertyData this[string name] { get; set; }
Parameters
Type Name Description
System.String name
Property Value
Type Description
PropertyData
Remarks

If property object does not have its Name specified it will be set when added to the collection. You cannot add a property with a different name than the collection name. When overridden in a derived class, make sure that the Exists implementation is syncronized with the override of this method.

Note! If IsReadOnly is true the indexer getter will use the GetHandler delegate to fetch data. It may return objects not present in the property collection (typically dynamic properties and fetch-data-from).

Keys

Gets a read-only collection of all the property names that is currently in the PropertyDataCollection.

Declaration
public virtual ICollection<string> Keys { get; }
Property Value
Type Description
System.Collections.Generic.ICollection<System.String>

LanguageBranch

Gets or sets the language of the IContent instance that owns the collection

Declaration
public virtual string LanguageBranch { get; set; }
Property Value
Type Description
System.String

The owner link.

Gets or sets the link to the IContent instance that owns the collection

Declaration
public virtual ContentReference OwnerLink { get; set; }
Property Value
Type Description
ContentReference

The owner link.

Methods

Add(PropertyData)

Add new property to the collection.

Declaration
public virtual void Add(PropertyData value)
Parameters
Type Name Description
PropertyData value

The PropertyData to add

Remarks

Uses the Name property from ProperyData as a key when adding PropertyData to the collection. Will fail if the key already exists.

Add(String, PropertyData)

Adds a new property.

Declaration
public virtual void Add(string name, PropertyData value)
Parameters
Type Name Description
System.String name

Name of property

PropertyData value

PropertyData to add

Remarks

Will fail if the key already exists.

Clear()

Removes all items from the PropertyDataCollection.

Declaration
public virtual void Clear()

Contains(String)

Determines whether the PropertyDataCollection contains a property with the specified name.

Declaration
public virtual bool Contains(string name)
Parameters
Type Name Description
System.String name

The name of the property to check for.

Returns
Type Description
System.Boolean

true if the property exists in the collection; otherwise false.

Remarks

This method will only check properties actually stored in the collection instance.

Copy()

Copies this instance.

Declaration
public virtual PropertyDataCollection Copy()
Returns
Type Description
PropertyDataCollection

A PropertyDataCollection.

Remarks

This method returns a deep copy of the collection.

CreateWritableClone()

Create a copy of the current object instance that is writable.

Declaration
public virtual PropertyDataCollection CreateWritableClone()
Returns
Type Description
PropertyDataCollection

A new copy of the object.

Remarks

The cloning is a deep-copy.

Get(String)

Gets the property specified by name.

Declaration
public virtual PropertyData Get(string name)
Parameters
Type Name Description
System.String name

The name of the property.

Returns
Type Description
PropertyData

The corresponding PropertyData object.

Remarks

This method will only return data actually stored in the collection instance. The default indexer may return data not in the collection (typically dynamic properties and fetch-data-from).

GetEnumerator()

Returns an enumerator that iterates through the collection of PropertyData objects.

Declaration
public virtual IEnumerator<PropertyData> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<PropertyData>

A System.Collections.Generic.IEnumerator<EPiServer.Core.PropertyData> that can be used to iterate through the collection.

GetPropertyValue<TPropertyValue>(String)

Gets the value of a property by the specified name and type.

Declaration
public TPropertyValue GetPropertyValue<TPropertyValue>(string name)
Parameters
Type Name Description
System.String name

The name of the property to retrieve.

Returns
Type Description
TPropertyValue

The value of the specified property.

Type Parameters
Name Description
TPropertyValue

The value type of the named property.

Exceptions
Type Condition
System.InvalidOperationException

Thrown when a property with the specified name or type could not be found.

InitializeData()

Used by classes derived from PropertyData to initialize themselves with additional information.

Declaration
public virtual void InitializeData()

MakeReadOnly()

Change the object instance into a read-only object.

Declaration
public virtual void MakeReadOnly()
Remarks

After calling this method, any attempt to change the object instance or any contained object will generate a System.NotSupportedException. I e the semantics is "deep read-only".

Note! After setting an object to read-only it is not possible to revert back to read-write mode. You will have to call the CreateWritableClone method to get a copy that can be modified.

Merge(PropertyDataCollection, PropertyDataCollection)

Merge two collection and keeping the correct fieldorder of the properties

Declaration
public static PropertyDataCollection Merge(PropertyDataCollection prop1, PropertyDataCollection prop2)
Parameters
Type Name Description
PropertyDataCollection prop1

First collection

PropertyDataCollection prop2

Second collection

Returns
Type Description
PropertyDataCollection

A new PropertyDataCollection with all the properties from both collections.

Remove(String)

Removes the item with the specified name from the PropertyDataCollection.

Declaration
public virtual bool Remove(string name)
Parameters
Type Name Description
System.String name

The name of the property to remove.

Returns
Type Description
System.Boolean

true if a property with the provided name was found and it was removed; otherwise false.

RemoveAt(Int32)

Removes the property at the specified location from the PropertyDataCollection.

Declaration
public virtual void RemoveAt(int index)
Parameters
Type Name Description
System.Int32 index

The index of the property to remove.

Set(String, PropertyData)

Sets the property with the specified name.

Declaration
public virtual void Set(string name, PropertyData value)
Parameters
Type Name Description
System.String name

The name of the property.

PropertyData value

The PropertyData object to set.

ShallowCopy()

Copies this instance.

Declaration
public virtual PropertyDataCollection ShallowCopy()
Returns
Type Description
PropertyDataCollection

A PropertyDataCollection.

Remarks

This method returns a shallow copy of the collection. I e the PropertyDataCollection returned is a new object, but the PropertyData objects in the collection are the same in the old and new PropertyDataCollection.

ThrowIfReadOnly()

Throws an System.NotSupportedException if the collection is set to read only.

Declaration
protected void ThrowIfReadOnly()

ToRawPropertyArray()

Convert the collection to an array of RawProperty objects.

Declaration
[Obsolete("Method is no longer in use and will be removed in a future release.")]
public RawProperty[] ToRawPropertyArray()
Returns
Type Description
RawProperty[]

A RawProperty array.

TryGetPropertyValue<TPropertyValue>(String, out TPropertyValue)

Attempts to get the value of a property by the specified name and type.

Declaration
public virtual bool TryGetPropertyValue<TPropertyValue>(string name, out TPropertyValue value)
Parameters
Type Name Description
System.String name

The name of the property to retrieve.

TPropertyValue value

The value of the property if the retrieval succeeded. If the retrieval failed it will be set to the default value of the specified type.

Returns
Type Description
System.Boolean

true if the retrieval succeeded, otherwise false.

Type Parameters
Name Description
TPropertyValue

The value type of the named property.

Remarks

The property with the specified name must exist, have a value type that matches or inherits TPropertyValue and have a value set for the attempt to be considered successful.

Explicit Interface Implementations

IReadOnly.CreateWritableClone()

Declaration
object IReadOnly.CreateWritableClone()
Returns
Type Description
System.Object

ICollection<PropertyData>.Contains(PropertyData)

Declaration
bool ICollection<PropertyData>.Contains(PropertyData item)
Parameters
Type Name Description
PropertyData item
Returns
Type Description
System.Boolean

ICollection<PropertyData>.CopyTo(PropertyData[], Int32)

Declaration
void ICollection<PropertyData>.CopyTo(PropertyData[] array, int arrayIndex)
Parameters
Type Name Description
PropertyData[] array
System.Int32 arrayIndex

ICollection<PropertyData>.Remove(PropertyData)

Declaration
bool ICollection<PropertyData>.Remove(PropertyData item)
Parameters
Type Name Description
PropertyData item
Returns
Type Description
System.Boolean

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
System.Collections.IEnumerator

Implements

System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable

Extension Methods