Compono.CompositionBuilder.Share T ()
Compono¶
Compono.CompositionBuilder¶
CompositionBuilder.Share\<T>() Method¶
Declares T graph-wide shared: within a single composition graph (one Create<T>() root, one CreateMany<T>() item, or one CompositionRow), the first request for T resolves through the normal pipeline and every subsequent request - regardless of source: an ordinary constructor parameter, a nested/transitive dependency, a provider, an exact registration, or an undecorated [Compose] theory parameter - receives that exact same instance. No [Shared] attribute is ever required to participate in a type declared shared this way. See docs/adr/0056-composition-builder-share-graph-wide-sharing.md.
Type parameters¶
T
The type to declare graph-wide shared.
Returns¶
Remarks¶
Configuration only - calling this does not construct T; the first real request within the graph does. Calling this more than once for the same T (directly, or from more than one profile) is idempotent, unlike Register<T>(Func<ICompositionContext,T>)'s strict duplicate-registration contract - there is no "which call wins" question to answer, since every call asserts the identical fact about the same type. Orthogonal to Register<T>(Func<ICompositionContext,T>): which stage produces T is unaffected by this call, and the two may be combined in either order with no precedence rule between them.