reflection

< Back


AssemblyExtensions

Namespace: Albatross.Reflection

Provides extension methods for Assembly objects to facilitate type discovery and resource management.

public static class AssemblyExtensions

Inheritance ObjectAssemblyExtensions
Attributes NullableContextAttribute, NullableAttribute, ExtensionAttribute

Methods

GetConcreteClasses<T>(Assembly)

Return all concrete classes that derive from base class T in an assembly

public static IEnumerable<Type> GetConcreteClasses<T>(Assembly assembly)

Type Parameters

T
The base type to filter by

Parameters

assembly Assembly
The assembly to search

Returns

IEnumerable<Type>
An enumerable of concrete types that derive from T

GetConcreteClasses(Assembly)

Return all Concrete classes in an assembly

public static IEnumerable<Type> GetConcreteClasses(Assembly assembly)

Parameters

assembly Assembly
The assembly to search

Returns

IEnumerable<Type>
An enumerable of all concrete types in the assembly

GetEmbeddedFile(Type, String, String)

Retrieves the content of an embedded resource file from the assembly. Uses the DefaultNamespaceAttribute if available, otherwise falls back to assembly name.

public static string GetEmbeddedFile(Type type, string name, string folder)

Parameters

type Type
A type from the assembly containing the embedded resource

name String
The name of the embedded file

folder String
The folder path within the assembly resources (default: “Embedded”)

Returns

String
The content of the embedded file as a string

Exceptions

ArgumentException
Thrown when the specified resource doesn’t exist

Remarks:

This method constructs the resource name as: {namespace}.{folder}.{name} If the assembly name doesn’t match the default namespace, use DefaultNamespaceAttribute.


< Back