Show / Hide Table of Contents

Class ObjectExtensions

Extension class used to provide various functionality to all CLR objects.

Inheritance
Object
ObjectExtensions
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.Util
Assembly: SoCore.dll
Syntax
public static class ObjectExtensions

Methods

AssignByReflection<T>(T, T)

Copies all public writable & public properties from the source-instance to the provided target instance. This operation is applied recursively for all non-primitive types, meaning that the two instances should be 100% independent and unable to mutate each others members. Fields and private members are not copied or assigned. If the type depends on private state to function, the copy may not work as expected.

Declaration
public static void AssignByReflection<T>(this T source, T destination)
    where T : new()
Parameters
Type Name Description
T source

Source instance

T destination

Targetinstance

Type Parameters
Name Description
T

Type of object whose properties we want to copy.

GraphCopy<T>(T)

Creates a copy of the provided object-graph by copying all public properties of the provided instance. This operation is applied recursively for all non-primitive types, meaning that the resulting instance should be 100% independent from the instance provided and that the two instances should be unable to mutate each others members. Fields and private members are not copied or assigned. If the type depends on private state to function, the copy may not work as expected.

Declaration
public static T GraphCopy<T>(this T source)
    where T : new()
Parameters
Type Name Description
T source

Source instance

Returns
Type Description
T

A 100% independent copy.

Type Parameters
Name Description
T

Type of object whose properties we want to copy.

© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top