Class ProtoRegistrationGuard
The public facade for the one internal once-only rule (ProtoRegistration): first registration
wins, later calls are no-ops. The guard reads through that helper for a service collection, a marker
with the caller's own identity rule, and a builder that keeps its marker out of DI, so an
integration's idempotency cannot drift from Core's.
public static class ProtoRegistrationGuard
- Inheritance
-
ProtoRegistrationGuard
- Inherited Members
Methods
Find<TMarker>(IServiceCollection, Func<TMarker, bool>)
Returns the registered marker instance matching matches, or
null. The read half of the once-only rule: a later caller can observe the
registration that won instead of deriving it again.
public static TMarker? Find<TMarker>(IServiceCollection services, Func<TMarker, bool> matches) where TMarker : class
Parameters
servicesIServiceCollectionmatchesFunc<TMarker, bool>
Returns
- TMarker
Type Parameters
TMarker
TryRegisterOnce<TMarker>(IServiceCollection)
Registers TMarker once and reports whether this call won. The marker is
the integration's own type, so its presence means exactly "this integration registered".
public static bool TryRegisterOnce<TMarker>(IServiceCollection services) where TMarker : class
Parameters
servicesIServiceCollection
Returns
Type Parameters
TMarker
TryRegisterOnce<TMarker>(IServiceCollection, TMarker, Func<TMarker, bool>)
Registers marker once and reports whether this call won.
matches is the caller's identity rule and decides what "already registered"
means, so an integration whose identity is a value - a target name, a transport - guards repeats
the same way the type-marker form does.
public static bool TryRegisterOnce<TMarker>(IServiceCollection services, TMarker marker, Func<TMarker, bool> matches) where TMarker : class
Parameters
servicesIServiceCollectionmarkerTMarkermatchesFunc<TMarker, bool>
Returns
Type Parameters
TMarker
TryRegisterOnce<TBuilder>(ConditionalWeakTable<TBuilder, object>, TBuilder)
The same rule for a builder whose marker lives in a weak table instead of the collection.
public static bool TryRegisterOnce<TBuilder>(ConditionalWeakTable<TBuilder, object> registrations, TBuilder builder) where TBuilder : class
Parameters
registrationsConditionalWeakTable<TBuilder, object>builderTBuilder
Returns
Type Parameters
TBuilder