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
instanceTThe object instance.
Returns
- Assembly
The assembly containing the object's type.
Type Parameters
TThe 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
assemblyAssemblyThe assembly to search.
manifestResourceNamestringThe name of the resource to find.
Returns
- Stream
A stream for the resource.
Exceptions
- ArgumentNullException
Thrown if
assemblyormanifestResourceNameis 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
assemblyAssemblyThe 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
TAttributeThe 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
assemblyAssemblyThe assembly to search.
Returns
- IEnumerable<(TAttribute Attribute, Type Type)>
An enumerable of tuples containing the attribute and the type.
Type Parameters
TAttributeThe attribute type.