Try our conversational search powered by Generative AI!

Class PropertyDataCollection

Collection of PropertyData objects.

Inheritance
System.Object
PropertyDataCollection
Implements
System.Collections.Generic.IEnumerable<PropertyData>
System.Collections.IEnumerable
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 7.19.2
Syntax
public class PropertyDataCollection : NameObjectCollectionBase, IReadOnly<PropertyDataCollection>, IReadOnly, IEnumerable<PropertyData>, IEnumerable
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(RawProperty[])

Initializes a new instance of the PropertyDataCollection class.

Declaration
public PropertyDataCollection(RawProperty[] properties)
Parameters
Type Name Description
RawProperty[] properties

The properties.

PropertyDataCollection(Int32)

Initializes a new instance of the PropertyDataCollection class.

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

The size of the collection.

PropertyDataCollection(SerializationInfo, StreamingContext)

Initializes a new instance of the PropertyDataCollection class.

Declaration
protected PropertyDataCollection(SerializationInfo info, StreamingContext context)
Parameters
Type Name Description
System.Runtime.Serialization.SerializationInfo info

A System.Runtime.Serialization.SerializationInfo object that contains the information required to serialize the new System.Collections.Specialized.NameObjectCollectionBase instance.

System.Runtime.Serialization.StreamingContext context

A System.Runtime.Serialization.StreamingContext object that contains the source and destination of the serialized stream associated with the new System.Collections.Specialized.NameObjectCollectionBase instance.

Properties

GetByIndexHandler

Gets or sets the handler for this property

Declaration
public static GetPropertyByIndexDelegate GetByIndexHandler { get; set; }
Property Value
Type Description
GetPropertyByIndexDelegate

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 bool IsReadOnly { get; }
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).

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 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 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 properties from the collection.

Declaration
public void Clear()

Copy()

Copies this instance.

Declaration
public 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 PropertyDataCollection CreateWritableClone()
Returns
Type Description
PropertyDataCollection

A new copy of the object.

Remarks

The cloning is a deep-copy.

ExistsLocally(String)

Checks if property exists in the local collection.

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

The name of the property.

Returns
Type Description
System.Boolean

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

FormatString(String)

Formats the string using properties.

Declaration
public string FormatString(string formatString)
Parameters
Type Name Description
System.String formatString
Returns
Type Description
System.String
Remarks

This is an extension to String.Format

Get(String)

Gets the property specified by name.

Declaration
public 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 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.

GetValue<TProperty>(String)

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

Declaration
public TProperty GetValue<TProperty>(string name)
Parameters
Type Name Description
System.String name

The name of the property to retrieve.

Returns
Type Description
TProperty

The property value.

Type Parameters
Name Description
TProperty

The type of the property value.

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 void InitializeData()

MakeReadOnly()

Change the object instance into a read-only object.

Declaration
public 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 a property with the given name.

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

RemoveAt(Int32)

Removes the property at the specified index.

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

Set(String, PropertyData)

Sets the property with the specified name.

Declaration
public 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 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
public RawProperty[] ToRawPropertyArray()
Returns
Type Description
RawProperty[]

A RawProperty array.

TryGetValue<TProperty>(String, out TProperty)

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

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

The name of the property to retrieve.

TProperty value

When this method returns, if the retrieval succeeded, contains the value of the property. If the retrieval failed (property did not exist with the specified name or type) it contains the default value of the specified type.

Returns
Type Description
System.Boolean

true if the retrieval succeeded, otherwise false.

Type Parameters
Name Description
TProperty

The type of the property value

Remarks

Returns false if the property does not exist in the collection, if TProperty does not match the type of the property, or if the value of the property is not set.

Explicit Interface Implementations

IReadOnly.CreateWritableClone()

Creates writable clone of this object.

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

Writable clone object.

IEnumerable.GetEnumerator()

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

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

An System.Collections.IEnumerator for the PropertyDataCollection instance.

Implements

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

Extension Methods