Class IdentityObjectExtensions
Provides extension methods for System.Object for working with Identity
Inheritance
System.Object
IdentityObjectExtensions
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.Data
Assembly: EPiServer.Data.dll
Version: 10.10.4Syntax
public static class IdentityObjectExtensions
Methods
GetIdentity(Object)
Extracts the identity from the object if it has one.
Declaration
public static Identity GetIdentity(this object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to check for identity |
Returns
Type | Description |
---|---|
Identity | A Identity instance or null if the object does implement its own identity |
Remarks
The algorith used to extract identity is as follows:
- The object is checked to see if it implements the IDynamicData interface and if so its Id property is called.
- The object is reflected to search for a property named Id with a getter whose type is either Identity or System.Guid
- The object is checked to see if it implements the IEntity interface and if so its ID and UniqueId properties are called
SetIdentity(Object, Identity)
Sets the identity into the object if supported
Declaration
public static void SetIdentity(this object value, Identity id)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The object to set the identity in |
Identity | id | The Identity to set |
Remarks
The algorith used to set identity is as follows:
- The object is checked to see if it implements the IDynamicData interface and if so its Id property is set.
- The object is reflected to search for a property named Id with a setter whose type is either Identity or System.Guid
- The object is checked to see if it implements the IEntity interface and if so its Id property is set.