Method Resolve<T>(IRouteContext?)
Resolves a service the context was given, looking in both places it can live: the services
set on the context itself (AddService, or a constructor argument), then the DI
container behind . Returns null when
neither holds one — the caller decides whether that is a default, its own instance, or a
refusal.
This is the shape a component needs when the host builds it by scanning: nothing can be
injected through its constructor, so the one shared instance is looked up instead. Having it
in one place keeps the two sources in one order everywhere — the metrics subscriber, the
template options and the shared HTTP host all resolve through it.
public static T? Resolve<T>(this IRouteContext? context) where T : class