Table of Contents

Class ReflectionUtils

Namespace
S1API.Utils
Assembly
S1API.dll

Provides reflection-based utility methods for mod developers.

public static class ReflectionUtils
Inheritance
ReflectionUtils
Inherited Members

Methods

GetMethod(Type?, string, BindingFlags)

Recursively searches for a method by name from a class down to the object type.

public static MethodInfo? GetMethod(Type? type, string methodName, BindingFlags bindingFlags)

Parameters

type Type

The type you want to recursively search.

methodName string

The name of the method you're searching for.

bindingFlags BindingFlags

The binding flags to apply during the search.

Returns

MethodInfo

The method info if found, otherwise null.

GetValueTupleItems(object)

Retrieves the items from the ValueTuple instance.

public static object[]? GetValueTupleItems(this object obj)

Parameters

obj object

The ValueTuple instance.

Returns

object[]

The items in the ValueTuple instance.

IsValueTuple(object)

Checks whether the object is a ValueTuple.

public static bool IsValueTuple(this object obj)

Parameters

obj object

The object type to check.

Returns

bool

Whether the type is a ValueTuple or not.

TryGetFieldOrProperty(object, string)

Attempts to get a field or property value from an object using reflection. Tries field first, then property. Handles both public and non-public members.

public static object? TryGetFieldOrProperty(object target, string memberName)

Parameters

target object

The target object to get the member from.

memberName string

The name of the field or property.

Returns

object

The value of the member, or null if not found or inaccessible.

TrySetFieldOrProperty(object, string, object?)

Attempts to set a field or property value on an object using reflection. Tries field first, then property. Handles both public and non-public members.

public static bool TrySetFieldOrProperty(object target, string memberName, object? value)

Parameters

target object

The target object to set the member on.

memberName string

The name of the field or property.

value object

The value to set.

Returns

bool

true if the member was successfully set; otherwise, false.