Skip to content

Compono.CompositionBuilder.AddProfile

Compono

Compono.CompositionBuilder

CompositionBuilder.AddProfile Method

Overloads
AddProfile(ICompositionProfile) Applies profile's Configure(CompositionBuilder) to this builder immediately, synchronously - the instance-based counterpart to AddProfile<TProfile>(), for a profile that needs constructor arguments or is already an instance.
AddProfile<TProfile>() Applies TProfile's Configure(CompositionBuilder) to this builder immediately, synchronously - constructed via its public parameterless constructor.

CompositionBuilder.AddProfile(ICompositionProfile) Method

Applies profile's Configure(CompositionBuilder) to this builder immediately, synchronously - the instance-based counterpart to AddProfile<TProfile>(), for a profile that needs constructor arguments or is already an instance.

public Compono.CompositionBuilder AddProfile(Compono.ICompositionProfile profile);

Parameters

profile ICompositionProfile

The profile instance to apply.

Returns

CompositionBuilder

Exceptions

CompositionConfigurationException
Applying profile would create a cycle (by its declared CLR type) - thrown immediately, containing exactly one ProfileCycle error naming the full chain.

CompositionBuilder.AddProfile\<TProfile>() Method

Applies TProfile's Configure(CompositionBuilder) to this builder immediately, synchronously - constructed via its public parameterless constructor.

public Compono.CompositionBuilder AddProfile<TProfile>()
    where TProfile : Compono.ICompositionProfile, new();

Type parameters

TProfile

The profile type to construct and apply.

Returns

CompositionBuilder

Exceptions

CompositionConfigurationException
Applying TProfile would create a cycle - thrown immediately, containing exactly one ProfileCycle error naming the full chain.

Remarks

If TProfile's constructor throws, that exception propagates unchanged from this call: its type, message, Diagnostic (for a CompositionException), System.Exception.InnerException chain, and original stack-trace frames are preserved, rather than being wrapped in a System.Reflection.TargetInvocationException. An exception thrown by Configure(CompositionBuilder) likewise propagates unchanged.

A profile applied while another profile of the exact same declared type is already applying (directly or nested several levels deep) is a cycle - see docs/adr/0018-composition-profiles.md.