Class ReflectionExtensions
- Namespace
- Plugin.BaseTypeExtensions
- Assembly
- Plugin.BaseTypeExtensions.dll
Provides extension methods for advanced reflection operations, including event field manipulation, hierarchy traversal, and assembly operations.
public static class ReflectionExtensions
- Inheritance
-
ReflectionExtensions
- Inherited Members
Methods
GetAssembly<T>(T)
Gets the assembly of the specified object instance.
public static Assembly GetAssembly<T>(this T instance) where T : class
Parameters
instance
TThe object instance.
Returns
- Assembly
The assembly containing the object's type.
Type Parameters
T
The type of the object.
GetResourceStream(Assembly, string)
Gets a resource stream from the specified assembly by resource name.
public static Stream GetResourceStream(this Assembly assembly, string manifestResourceName)
Parameters
assembly
AssemblyThe assembly to search.
manifestResourceName
stringThe name of the resource to find.
Returns
- Stream
A stream for the resource.
Exceptions
- ArgumentNullException
Thrown if
assembly
ormanifestResourceName
is null.- FileNotFoundException
Thrown if the resource is not found or multiple matches are found.
GetTypesWithAttributeAsync<TAttribute>(Assembly)
Asynchronously gets all types in the specified assembly that have the specified attribute.
public static Task<List<(TAttribute Attribute, Type Type)>> GetTypesWithAttributeAsync<TAttribute>(this Assembly assembly) where TAttribute : Attribute
Parameters
assembly
AssemblyThe assembly to search.
Returns
- Task<List<(TAttribute Attribute, Type Type)>>
A task representing the asynchronous operation, with a list of tuples containing the attribute and the type.
Type Parameters
TAttribute
The attribute type.
GetTypesWithAttribute<TAttribute>(Assembly)
Gets all types in the specified assembly that have the specified attribute.
public static IEnumerable<(TAttribute Attribute, Type Type)> GetTypesWithAttribute<TAttribute>(this Assembly assembly) where TAttribute : Attribute
Parameters
assembly
AssemblyThe assembly to search.
Returns
- IEnumerable<(TAttribute Attribute, Type Type)>
An enumerable of tuples containing the attribute and the type.
Type Parameters
TAttribute
The attribute type.