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.
ViewModelCompositionOptions is the central configuration object for the ServiceComposer pipeline. An instance is created internally by AddViewModelComposition and passed to the optional Action<ViewModelCompositionOptions> callback before the DI container is finalized. Through its properties and methods you can control which assemblies are scanned, how responses are serialized, whether write endpoints are active, and how individual composition handlers are registered and configured in the DI container.
Properties
AssemblyScanner
AssemblyScanner instance used to discover composition handlers at startup. Use this to disable automatic scanning or add inclusion/exclusion filters. See the Assembly Scanner reference for full details.
Services
IServiceCollection. Use this inside AddTypesRegistrationHandler or AddServicesConfigurationHandler callbacks to register additional services alongside discovered types.
Configuration
IConfiguration root passed to AddViewModelComposition. Accessing this property throws ArgumentException when no IConfiguration was supplied to AddViewModelComposition. Pass the configuration instance explicitly to avoid this:
ResponseSerialization
JsonSerializerOptions. See the Response Serialization Options reference for full details.
Methods
EnableCompositionOverControllers
When
true (default), route template comparisons between handlers and controller
actions ignore letter case. Set to false to enforce case-sensitive matching.DisableWriteSupport
MapCompositionHandlers from registering POST, PUT, PATCH, and DELETE endpoints. Use this in read-only gateway scenarios to reduce the exposed surface area.
RegisterCompositionHandler<T>
T must implement ICompositionRequestsHandler, ICompositionEventsSubscriber, ICompositionEventsHandler<TEvent>, or IEndpointScopedViewModelFactory.
RegisterGlobalViewModelFactory<T>
IViewModelFactory that creates the ViewModel object for every composed request. Only one global factory can be registered; registering a second throws NotSupportedException.
RegisterEndpointScopedViewModelFactory<T>
T’s CreateViewModel method. Multiple endpoint-scoped factories can coexist, each handling a different route.
AddServicesConfigurationHandler
RegisterCompositionHandler call) encounters serviceType, it invokes configurationHandler instead of the default services.AddTransient(type). Use this to register a handler as a singleton, keyed service, or with a factory delegate.
The composition handler type whose registration should be customized.
Throws
NotSupportedException if a handler is already registered for this type.Delegate receiving the concrete type and the service collection. Perform the
custom registration inside this delegate.
AddTypesRegistrationHandler
typesFilter returns true. Use this to auto-register types that are not first-class ServiceComposer concepts (e.g., custom validators or enrichers).
Predicate that receives a candidate type and returns
true if the
registrationHandler should receive it.Callback that receives all matching types and is responsible for registering
them in
Services.