Class TypesExtensions
- Namespace
- HeroKit.Types
- Assembly
- HeroKit.dll
Provides extension methods for Type values.
public static class TypesExtensions
- Inheritance
-
TypesExtensions
- Inherited Members
Methods
GetDefault(Type)
Retrieves the default value for a given type.
[UnconditionalSuppressMessage("Trimming", "IL2067", Justification = "Only value types reach Activator.CreateInstance. Value types always have a default value and need no constructor.")]
public static object? GetDefault(this Type type)
Parameters
typeTypeThe type for which to retrieve the default value.
Returns
- object
The default value of the specified type, or null if not applicable.
GetExtensionMethod(Type, IEnumerable<Assembly>, string)
Gets a specific extension method for the specified type from a collection of assemblies.
[RequiresUnreferencedCode("Scans assembly types with reflection. Types and methods may be removed by trimming.")]
public static MethodInfo? GetExtensionMethod(this Type type, IEnumerable<Assembly> assemblies, string name)
Parameters
typeTypeThe type to get the extension method for.
assembliesIEnumerable<Assembly>The collection of assemblies containing extension methods.
namestringThe name of the extension method.
Returns
- MethodInfo
The MethodInfo of the specified extension method, or null if not found.
GetExtensionMethod(Type, Assembly, string)
Gets a specific extension method for the specified type from a given assembly.
[RequiresUnreferencedCode("Scans assembly types with reflection. Types and methods may be removed by trimming.")]
public static MethodInfo? GetExtensionMethod(this Type type, Assembly extensionsAssembly, string name)
Parameters
typeTypeThe type to get the extension method for.
extensionsAssemblyAssemblyThe assembly containing extension methods.
namestringThe name of the extension method.
Returns
- MethodInfo
The MethodInfo of the specified extension method, or null if not found.
GetExtensionMethod(Type, Assembly, string, Type[])
Gets a specific extension method with the given name and parameter types for the specified type from an assembly.
[RequiresUnreferencedCode("Scans assembly types with reflection. Types and methods may be removed by trimming.")]
public static MethodInfo? GetExtensionMethod(this Type type, Assembly extensionsAssembly, string name, Type[] types)
Parameters
typeTypeThe type to get the extension method for.
extensionsAssemblyAssemblyThe assembly containing extension methods.
namestringThe name of the extension method.
typesType[]An array of parameter types for the extension method.
Returns
- MethodInfo
The MethodInfo of the specified extension method, or null if not found.
GetExtensionMethods(Type, Assembly, BindingFlags)
Gets extension methods for the specified type from a given assembly.
[RequiresUnreferencedCode("Scans assembly types with reflection. Types and methods may be removed by trimming.")]
public static IEnumerable<MethodInfo> GetExtensionMethods(this Type type, Assembly extensionsAssembly, BindingFlags bindingFlags = BindingFlags.Static | BindingFlags.Public)
Parameters
typeTypeThe type to get extension methods for.
extensionsAssemblyAssemblyThe assembly containing extension methods.
bindingFlagsBindingFlagsBinding flags to control the method visibility.
Returns
- IEnumerable<MethodInfo>
An enumerable collection of extension methods for the specified type.
GetRealType(Type)
Gets the concrete implementation type for a given interface or abstract type.
[RequiresUnreferencedCode("Scans exported types with reflection. Types may be removed by trimming.")]
public static Type? GetRealType(this Type type)
Parameters
typeTypeThe interface or abstract type to get the implementation for.
Returns
- Type
The concrete implementation type, or null if not found.