Show / Hide Table of Contents

Class ReflectionHelper

Various utility methods aiding Reflection tasks.
Inheritance
System.Object
ReflectionHelper
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Jotunn.Utils
Assembly: Jotunn.dll
Syntax
public static class ReflectionHelper

Fields

| Improve this Doc View Source

AllBindingFlags

All possible binding flags
Declaration
public const BindingFlags AllBindingFlags = BindingFlags.CreateInstance | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.GetProperty | BindingFlags.IgnoreCase | BindingFlags.IgnoreReturn | BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.OptionalParamBinding | BindingFlags.Public | BindingFlags.PutDispProperty | BindingFlags.PutRefDispProperty | BindingFlags.SetField | BindingFlags.SetProperty | BindingFlags.Static | BindingFlags.SuppressChangeType
Field Value
Type Description
System.Reflection.BindingFlags

Methods

| Improve this Doc View Source

GetCallingAssembly()

Get the System.Reflection.Assembly of the first caller outside of this assembly
Declaration
public static Assembly GetCallingAssembly()
Returns
Type Description
System.Reflection.Assembly The assembly of the first caller outside of this assembly
| Improve this Doc View Source

GetCallingType()

Get the System.Type.ReflectedType of the first caller outside of this assembly
Declaration
public static Type GetCallingType()
Returns
Type Description
System.Type The reflected type of the first caller outside of this assembly
| Improve this Doc View Source

GetEnumeratedType(Type)

Get the generic System.Collections.IEnumerable type of this type.
https://stackoverflow.com/a/21995826
Declaration
public static Type GetEnumeratedType(this Type type)
Parameters
Type Name Description
System.Type type this type
Returns
Type Description
System.Type
| Improve this Doc View Source

GetPrivateField<T>(Object, String)

Get the value of a private field of any class instance
Declaration
public static T GetPrivateField<T>(object instance, string name)
Parameters
Type Name Description
System.Object instance Instance of the class
System.String name Name of the field
Returns
Type Description
T The value of the field
Type Parameters
Name Description
T Generic field type
| Improve this Doc View Source

GetPrivateField<T>(Type, String)

Get the value of a private static field of any class
Declaration
public static T GetPrivateField<T>(Type type, string name)
Parameters
Type Name Description
System.Type type Type of the class
System.String name Name of the field
Returns
Type Description
T The value of the field
Type Parameters
Name Description
T Generic field type
| Improve this Doc View Source

GetPrivateProperty<T>(Object, String)

Get the value of a private property of any class instance
Declaration
public static T GetPrivateProperty<T>(object instance, string name)
Parameters
Type Name Description
System.Object instance Instance of the class
System.String name Name of the property
Returns
Type Description
T The value of the property
Type Parameters
Name Description
T Generic property type
| Improve this Doc View Source

HasImplementedRawGeneric(Type, Type)

Determine whether the specified type type is a subtype of the specified generic type or implements the specified generic interface.
Declaration
public static bool HasImplementedRawGeneric(this Type type, Type generic)
Parameters
Type Name Description
System.Type type the type to be tested.
System.Type generic generic interface type, passing in typeof (IXxx<>)
Returns
Type Description
System.Boolean returns true if it is a subtype of the generic interface, or false.
| Improve this Doc View Source

InvokePrivate(Object, String, Object[])

Invoke a private method of any class instance
Declaration
public static object InvokePrivate(object instance, string name, object[] args = null)
Parameters
Type Name Description
System.Object instance Instance of the class
System.String name Name of the method
System.Object[] args Argument values (if any) of the method
Returns
Type Description
System.Object The return of the method as an System.Object
| Improve this Doc View Source

IsEnumerable(Type)

Determines if this type inherits from System.Collections.IEnumerable
Declaration
public static bool IsEnumerable(this Type type)
Parameters
Type Name Description
System.Type type this type
Returns
Type Description
System.Boolean
| Improve this Doc View Source

IsSameOrSubclass(Type, Type)

Determines whether this type is the same or a subclass of another type
Declaration
public static bool IsSameOrSubclass(this Type type, Type base)
Parameters
Type Name Description
System.Type type this type
System.Type base Type against the type is checked
Returns
Type Description
System.Boolean true if this type is the same or a subtype
| Improve this Doc View Source

SetPrivateField(Object, String, Object)

Set a value of a private field of any class instance
Declaration
public static void SetPrivateField(object instance, string name, object value)
Parameters
Type Name Description
System.Object instance Instance of the class
System.String name Name of the field
System.Object value New value of the field
  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾