Class ReflectedTypeAttribute
Marks an interface or base class to indicate that its concrete implementations should be discovered and loaded automatically at runtime through reflection.
Inherited Members
Namespace: Scylla.Core.Attributes
Assembly: ScyllaCore.dll
Syntax
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
public sealed class ReflectedTypeAttribute : Attribute
Remarks
The Scylla framework supports a plugin-style extensibility model in which concrete implementations of an interface or base class are discovered without requiring explicit registration. Applying ReflectedTypeAttribute to an interface or class signals the discovery system that it should scan loaded assemblies for types that implement or inherit from the decorated type.
There are two discovery modes, selected by which constructor is used:
-
Auto-discovery mode (parameterless constructor): all
non-abstract concrete types that implement the decorated interface or
extend the decorated class are found via reflection across all loaded
assemblies. Abstract classes are excluded by default; set
IncludeAbstract to
trueto include them. - Explicit-type mode (constructor with Type parameter): only the specific type passed to the constructor is loaded. This is useful when a particular default implementation should be used unconditionally, bypassing broader reflection scanning.
Because AllowMultiple = true, you can apply this attribute more than once
on the same interface or class to register several explicit implementation types
simultaneously. Combined with the parameterless form, this allows declaring a
mix of auto-discovered and explicitly pinned implementations.
This attribute is non-inherited (Inherited = false). Sub-interfaces or
derived abstract classes that also need discovery support must declare their own
ReflectedTypeAttribute.
Common use cases include:
- Plugin systems where third-party code registers new implementations without modifying the core framework.
- Service-locator or dependency-injection patterns where concrete providers are discovered at startup rather than wired up manually.
- Editor tools that enumerate all registered strategy or handler types to populate a selection UI.
Auto-discovery mode - all implementations of the interface are found:
[ReflectedType]
public interface IWeapon
{
void Attack();
}
/* SwordWeapon, BowWeapon, etc. are found automatically at runtime. */
Auto-discovery including abstract classes - useful when the system should enumerate partial implementations as well:
[ReflectedType(IncludeAbstract = true)]
public interface ISerializer
{
string Serialize(object value);
}
Explicit-type mode - pin a specific implementation unconditionally:
[ReflectedType(typeof(DefaultAudioProvider))]
public interface IAudioProvider
{
void PlaySound(string soundID);
}
Multiple explicit types registered on the same interface:
[ReflectedType(typeof(PrimaryRenderer))]
[ReflectedType(typeof(FallbackRenderer))]
public interface IRenderer
{
void Render();
}
Reading all attribute instances from an interface via reflection:
var attrs = typeof(IWeapon).GetCustomAttributes<ReflectedTypeAttribute>();
foreach (var attr in attrs)
{
if (attr.ImplementationType != null)
Debug.Log($"Explicit: {attr.ImplementationType.Name}");
else
Debug.Log($"Auto-discovery (include abstract: {attr.IncludeAbstract})");
}
Constructors
ReflectedTypeAttribute()
Initializes a new ReflectedTypeAttribute in auto-discovery mode, instructing the discovery system to find all qualifying implementations of the decorated type by scanning loaded assemblies.
Declaration
public ReflectedTypeAttribute()
Remarks
In this mode, ImplementationType is null and
IncludeAbstract defaults to false. To also include abstract
classes in the results, set IncludeAbstract to true via the
property initializer:
[ReflectedType(IncludeAbstract = true)]
ReflectedTypeAttribute(Type)
Initializes a new ReflectedTypeAttribute in explicit-type mode, pinning a specific implementation type that the discovery system should load without performing broader assembly scanning.
Declaration
public ReflectedTypeAttribute(Type implementationType)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | implementationType | The concrete (or abstract) Type to register as an implementation
of the decorated interface or base class. Must be non- |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown when |
Properties
ImplementationType
Gets the specific implementation type that the discovery system should load when operating in explicit-type mode.
Declaration
public Type ImplementationType { get; }
Property Value
| Type | Description |
|---|---|
| Type | The Type supplied to the
ReflectedTypeAttribute(Type) constructor, or |
IncludeAbstract
Gets or sets whether abstract classes should be included when the discovery system scans for implementations in auto-discovery mode.
Declaration
public bool IncludeAbstract { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Remarks
Set this property via the attribute initializer syntax:
[ReflectedType(IncludeAbstract = true)]
Enabling this option is uncommon in production scenarios but can be useful for tooling that needs to enumerate all partial implementations of an interface for documentation or analysis purposes.