Show / Hide Table of Contents

Class Objects

Object manipulation functions.

Inheritance
object
Objects
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: TheXDS.MCART.Helpers
Assembly: MCART.dll
Syntax
public static class Objects

Methods

| Edit this page View Source

AreAllNull(params object?[])

Determines if all objects are null.

Declaration
public static bool AreAllNull(params object?[] collection)
Parameters
Type Name Description
object[] collection

Objects to check.

Returns
Type Description
bool

true if all objects are null; otherwise, false.

Exceptions
Type Condition
ArgumentNullException

Thrown if collection is null.

| Edit this page View Source

FromBytes<T>(byte[])

Gets a value of type T from a byte array using marshaling.

Declaration
public static T FromBytes<T>(byte[] rawBytes) where T : struct
Parameters
Type Name Description
byte[] rawBytes

Bytes to convert into the value.

Returns
Type Description
T

A value of type T created from the byte array.

Type Parameters
Name Description
T

Type of value to retrieve. Must be a structure.

Remarks

Fields of type string in the structure must be decorated with:

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = <max size>)]
See Also
GetBytes<T>(T)
| Edit this page View Source

GetAttribute<T, TIt>()

Returns the attribute associated with the specified type declaration.

Declaration
public static T? GetAttribute<T, TIt>() where T : Attribute
Returns
Type Description
T

An attribute of type T with the data associated with the type declaration.

Type Parameters
Name Description
T

Type of attribute to return. Must inherit from Attribute.

TIt

Type from which to extract the attribute.

| Edit this page View Source

GetBytes<T>(T)

Gets a byte array from a value of type T using marshaling.

Declaration
public static byte[] GetBytes<T>(T value) where T : struct
Parameters
Type Name Description
T value

Value to convert to bytes.

Returns
Type Description
byte[]

A byte array that can be used to reconstruct the value.

Type Parameters
Name Description
T

Type of value to convert to bytes.

Remarks

Fields of type string in the structure must be decorated with:

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = <max size>)]
See Also
FromBytes<T>(byte[])
| Edit this page View Source

IsAnyNull(params object?[])

Determines if any of the objects is null.

Declaration
public static bool IsAnyNull(params object?[] x)
Parameters
Type Name Description
object[] x

Objects to check.

Returns
Type Description
bool

true if any object is null; otherwise, false.

| Edit this page View Source

Itself<T>(T)

Returns a circular reference to this object.

Declaration
public static T Itself<T>(this T obj)
Parameters
Type Name Description
T obj

Object.

Returns
Type Description
T

This object.

Type Parameters
Name Description
T

Type of this object.

Remarks

This function is only useful when using Visual Basic with the With structure.

| Edit this page View Source

ShallowClone<T>(T)

Creates a new copy of the object.

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

Source object.

Returns
Type Description
T

A new instance of type T with the same values as source in its public fields and read/write properties.

Type Parameters
Name Description
T

Type of object to clone.

| Edit this page View Source

ShallowCopyTo(object, object, Type)

Copies the property values from one object to another.

Declaration
public static void ShallowCopyTo(this object source, object destination, Type objectType)
Parameters
Type Name Description
object source

Source object.

object destination

Destination object.

Type objectType

Type of objects to copy. Limits the copy to properties and fields accessible within the specified type.

| Edit this page View Source

ShallowCopyTo<T>(T, T)

Copies the property values from one object to another.

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

Source object.

T destination

Destination object.

Type Parameters
Name Description
T

Type of objects to operate on.

| Edit this page View Source

ToTypes(params object[])

Gets a list of the types of the specified objects.

Declaration
public static IEnumerable<Type> ToTypes(params object[] objects)
Parameters
Type Name Description
object[] objects

Objects to generate the type collection from.

Returns
Type Description
IEnumerable<Type>

A list of the types of the provided objects.

| Edit this page View Source

TryCreateDelegate<T>(MethodInfo, object, out T?)

Encapsulates CreateDelegate(Type, object, string, bool, bool) to ensure all possible exceptions are caught.

Declaration
public static bool TryCreateDelegate<T>(MethodInfo method, object instance, out T? @delegate) where T : notnull, Delegate
Parameters
Type Name Description
MethodInfo method

Method to create the delegate from.

object instance

Instance to bind the delegate to.

T delegate

Created delegate. null if the delegate could not be created.

Returns
Type Description
bool

true if the delegate was successfully created; otherwise, false.

Type Parameters
Name Description
T

Type of delegate to create.

Remarks

This method was created due to a quirk in CreateDelegate(Type, object, string, bool, bool), where it may still throw an exception if the method contains generic parameters.

| Edit this page View Source

TryCreateDelegate<T>(MethodInfo, out T?)

Safe version of CreateDelegate(Type, MethodInfo, bool).

Declaration
public static bool TryCreateDelegate<T>(MethodInfo method, out T? @delegate) where T : notnull, Delegate
Parameters
Type Name Description
MethodInfo method

Method to create the delegate from.

T delegate

Created delegate. null if the delegate could not be created.

Returns
Type Description
bool

true if the delegate was successfully created; otherwise, false.

Type Parameters
Name Description
T

Type of delegate to create.

Remarks

This method was created due to a quirk in CreateDelegate(Type, MethodInfo, bool), where it may still throw an exception if the method contains generic parameters.

| Edit this page View Source

WhichAreNull(params object?[])

Determines which objects are null.

Declaration
public static IEnumerable<int> WhichAreNull(params object?[] collection)
Parameters
Type Name Description
object[] collection

Collection of objects to check.

Returns
Type Description
IEnumerable<int>

An enumerator with the indices of objects that are null.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX