Class ReflectionHelper
Provides utility methods for reflection-related operations.
Inherited Members
Namespace: mk.helpers
Assembly: mk.helpers.dll
Syntax
public static class ReflectionHelper
Methods
Changes(object, object)
Determines the changes between two objects and returns a list of EntityChange instances.
Declaration
public static List<EntityChange> Changes(this object oldEntity, object newEntity)
Parameters
| Type | Name | Description |
|---|---|---|
| object | oldEntity | The old object. |
| object | newEntity | The new object. |
Returns
| Type | Description |
|---|---|
| List<EntityChange> | A list of EntityChange instances representing the changes. |
CopyProperties(object, object, out List<EntityChange>)
Copies the properties from the source object to the destination object and captures the changes made.
Declaration
public static void CopyProperties(this object source, object destination, out List<EntityChange> changes)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
| object | destination | The destination object. |
| List<EntityChange> | changes | The list of changes made during copying. |
CopyProperties(object, object, out List<EntityChange>, params string[])
Copies the properties from the source object to the destination object, ignoring specified properties, and captures the changes made.
Declaration
public static void CopyProperties(this object source, object destination, out List<EntityChange> changes, params string[] ignore)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
| object | destination | The destination object. |
| List<EntityChange> | changes | The list of changes made during copying. |
| string[] | ignore | An array of property names to ignore during copying. |
CopyProperties(object, object, params string[])
Copies the properties from the source object to the destination object, ignoring specified properties.
Declaration
public static void CopyProperties(this object source, object destination, params string[] ignore)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
| object | destination | The destination object. |
| string[] | ignore | An array of property names to ignore during copying. |
CopyPropertiesFrom(object, object, out List<EntityChange>)
Copies the properties from the source object to the destination object and returns the changes made.
Declaration
public static void CopyPropertiesFrom(this object source, object destination, out List<EntityChange> changes)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
| object | destination | The destination object. |
| List<EntityChange> | changes | The list of changes made during copying. |
CopyPropertiesFrom(object, object, params string[])
Copies the properties from the source object to the destination object, ignoring specified properties.
Declaration
public static void CopyPropertiesFrom(this object source, object destination, params string[] ignore)
Parameters
| Type | Name | Description |
|---|---|---|
| object | source | The source object. |
| object | destination | The destination object. |
| string[] | ignore | An array of property names to ignore during copying. |
DeepClone<T>(T)
Creates a deep clone of the provided object using JSON serialization.
Declaration
public static T DeepClone<T>(this T obj)
Parameters
| Type | Name | Description |
|---|---|---|
| T | obj | The object to be cloned. |
Returns
| Type | Description |
|---|---|
| T | The deep-cloned object. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the object to clone. |
GetUnderlyingType(MemberInfo)
Retrieves the underlying type of a member (event, field, method, or property).
Declaration
public static Type GetUnderlyingType(this MemberInfo member)
Parameters
| Type | Name | Description |
|---|---|---|
| MemberInfo | member | The member to retrieve the underlying type for. |
Returns
| Type | Description |
|---|---|
| Type | The underlying type of the member. |
IsPrimitive(Type)
Checks if the provided type is a primitive type.
Declaration
public static bool IsPrimitive(this Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsSimpleType(Type)
Checks if the provided type is a simple type (value type, primitive type, or simple reference type).
Declaration
public static bool IsSimpleType(this Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | The type to be checked. |
Returns
| Type | Description |
|---|---|
| bool |
|
PublicPropertiesEqual<T>(T, T, params string[])
Compares the public properties of two objects of the same type and checks if they are equal.
Declaration
public static bool PublicPropertiesEqual<T>(this T self, T to, params string[] ignore) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| T | self | The first object. |
| T | to | The second object. |
| string[] | ignore | A list of property names to ignore during comparison. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The type of the objects to compare. |