Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ServiceComposer/ServiceComposer.AspNetCore/llms.txt
Use this file to discover all available pages before exploring further.
AssemblyScanner drives ServiceComposer’s automatic handler discovery at application startup. When enabled (the default), it loads every *.dll and *.exe file it can find — from the currently loaded AppDomain assemblies, the application base directory, and the TRUSTED_PLATFORM_ASSEMBLIES list — and then reflects over the types in those assemblies to register composition components into the DI container.
The scanner recognises the following interfaces and attributes and registers matching types automatically:
| Interface / Attribute | Registered as |
|---|---|
ICompositionRequestsHandler | Transient composition handler |
ICompositionEventsSubscriber | Transient composition handler |
ICompositionEventsHandler<T> | Transient event handler |
IViewModelFactory | Transient global ViewModel factory |
IEndpointScopedViewModelFactory | Transient endpoint-scoped factory |
ICompositionRequestFilter / ICompositionRequestFilter<T> | Transient request filter |
IViewModelPreviewHandler | Transient preview handler |
IViewModelCompositionOptionsCustomization | Instantiated at startup to customize ViewModelCompositionOptions |
AssemblyScanner instance is exposed as the AssemblyScanner property on ViewModelCompositionOptions and is configured during the AddViewModelComposition callback.
Properties
IsEnabled
true when the scanner will run at startup (the default); false after Disable() has been called. Read-only from outside the class — use Disable() to change the value.
DirectorySearchOptions
AppContext.BaseDirectory searches only the top-level directory or recurses into subdirectories.
SearchOption.TopDirectoryOnly (default) — only the base directory is searched.
SearchOption.AllDirectories — all subdirectories are also searched.Methods
Disable
ViewModelCompositionOptions.RegisterCompositionHandler<T>() or AddTypesRegistrationHandler.
AddAssemblyFilter
FilterResults.Include to allow it or FilterResults.Exclude to skip it. All registered filters must return Include for an assembly to be loaded; a single Exclude from any filter causes the assembly to be skipped.
A delegate that receives the assembly’s full path and returns
FilterResults.Include or FilterResults.Exclude.FilterResults Enum
AddAssemblyFilter delegate.
| Value | Integer | Meaning |
|---|---|---|
Exclude | 0 | Skip this assembly; do not load or reflect over it. |
Include | 1 | Allow this assembly to be loaded and scanned. |
How scanning works
At the end ofAddViewModelComposition, the scanner performs the following steps:
- Iterates over every assembly already loaded into
AppDomain.CurrentDomain. - Searches
AppContext.BaseDirectoryfor*.dlland*.exefiles usingDirectorySearchOptions. - Searches the
TRUSTED_PLATFORM_ASSEMBLIESlist (present in single-file and trimmed deployments). - For each candidate path, validates it is a .NET managed assembly and is not a Microsoft runtime assembly (using a public-key-token check). Invalid or runtime assemblies are silently skipped.
- Applies all registered filters; any
Excluderesult drops the assembly. - Loads qualifying assemblies and reflects over all public non-abstract types.
- Invokes every
IViewModelCompositionOptionsCustomizationfound, then runs each registeredtypesRegistrationHandleragainst the filtered type list.