Class ModelAttributeCollection

Attributes on models. This class are used by the ContentTypeModel and PropertyDefinitionModel to add the class attributes to the models.

Inheritance
System.Object
ModelAttributeCollection
Namespace: EPiServer.DataAbstraction.RuntimeModel
Assembly: EPiServer.dll
Version: 12.0.3
Syntax
public class ModelAttributeCollection : Object

Constructors

ModelAttributeCollection()

Declaration
public ModelAttributeCollection()

Methods

AddAttribute(Attribute)

Adds an attribute to the attribute list.

Declaration
public void AddAttribute(Attribute attribute)
Parameters
Type Name Description
System.Attribute attribute

The attribute.

AttributeExist<T>()

Returns true if the T. exist on the model, otherwise false.

Declaration
public bool AttributeExist<T>()
    where T : Attribute
Returns
Type Description
System.Boolean

True if the attribute exist, otherwise false.

Type Parameters
Name Description
T

The attribute type to look for.

GetAllAttributes<T>()

Gets all attributes of type T.

Declaration
public IEnumerable<T> GetAllAttributes<T>()
    where T : Attribute
Returns
Type Description
System.Collections.Generic.IEnumerable<T>

All attribute of type T. If no attributes are found ot the type, an empty list will be returned.

Type Parameters
Name Description
T

The attribute type.

GetSingleAttribute<T>()

Gets the attribute of the type T.

Declaration
public T GetSingleAttribute<T>()
    where T : Attribute
Returns
Type Description
T

The attribute of type T. If there are no attribute of the type, null will be returned.

Type Parameters
Name Description
T

The attribute type.

Exceptions
Type Condition
System.InvalidOperationException

If more than one attribute of the type T are found.

TryGetSingleAttribute<T>(out T)

Tries to get the attribute of the type T.

Declaration
public bool TryGetSingleAttribute<T>(out T attribute)
    where T : Attribute
Parameters
Type Name Description
T attribute

The returned attribute.

Returns
Type Description
System.Boolean

True if one, and only one, attribute was found, otherwice false.

Type Parameters
Name Description
T

The attribute type.

Extension Methods