Class CompositionContainerBuilderBase<TBuilder>
Base class for composition container builders.
Inheritance
Implements
Inherited Members
Namespace: Kephas.Composition.Hosting
Assembly: Kephas.Core.dll
Syntax
public abstract class CompositionContainerBuilderBase<TBuilder> : ICompositionContainerBuilder where TBuilder : CompositionContainerBuilderBase<TBuilder>
Type Parameters
Name | Description |
---|---|
TBuilder | The type of the builder. |
Constructors
| Improve this Doc View SourceCompositionContainerBuilderBase(ICompositionRegistrationContext)
Initializes a new instance of the CompositionContainerBuilderBase<TBuilder> class.
Declaration
protected CompositionContainerBuilderBase(ICompositionRegistrationContext context)
Parameters
Type | Name | Description |
---|---|---|
ICompositionRegistrationContext | context | The context. |
Properties
| Improve this Doc View SourceAppRuntime
Gets the application runtime.
Declaration
public IAppRuntime AppRuntime { get; }
Property Value
Type | Description |
---|---|
IAppRuntime | The application runtime. |
CompositionParts
Gets the composition parts.
Declaration
protected HashSet<Type> CompositionParts { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.HashSet<System.Type> | The composition parts. |
ConventionsBuilder
Gets the conventions builder.
Declaration
protected IConventionsBuilder ConventionsBuilder { get; }
Property Value
Type | Description |
---|---|
IConventionsBuilder | The conventions builder. |
Logger
Gets the logger.
Declaration
protected ILogger Logger { get; }
Property Value
Type | Description |
---|---|
ILogger | The logger. |
LogManager
Gets the log manager.
Declaration
public ILogManager LogManager { get; }
Property Value
Type | Description |
---|---|
ILogManager | The log manager. |
Registry
Gets the IAppServiceInfo registry.
Declaration
protected CompositionContainerBuilderBase<TBuilder>.AppServiceInfoRegistry Registry { get; }
Property Value
Type | Description |
---|---|
CompositionContainerBuilderBase.AppServiceInfoRegistry<> | The registry. |
TypeLoader
Gets the type loader.
Declaration
public ITypeLoader TypeLoader { get; }
Property Value
Type | Description |
---|---|
ITypeLoader | The type loader. |
Methods
| Improve this Doc View SourceAssertRequiredService<TService>(TService)
Asserts the the required service is not missing.
Declaration
protected void AssertRequiredService<TService>(TService service)
Parameters
Type | Name | Description |
---|---|---|
TService | service | The service. |
Type Parameters
Name | Description |
---|---|
TService | Type of the service. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when the requested operation is invalid. |
CreateContainer()
Creates the container with the provided configuration asynchronously.
Declaration
public virtual ICompositionContext CreateContainer()
Returns
Type | Description |
---|---|
ICompositionContext | A new container with the provided configuration. |
CreateContainerCore(IConventionsBuilder, IEnumerable<Type>)
Creates a new composition container based on the provided conventions and assembly parts.
Declaration
protected abstract ICompositionContext CreateContainerCore(IConventionsBuilder conventions, IEnumerable<Type> parts)
Parameters
Type | Name | Description |
---|---|---|
IConventionsBuilder | conventions | The conventions. |
System.Collections.Generic.IEnumerable<System.Type> | parts | The parts candidating for composition. |
Returns
Type | Description |
---|---|
ICompositionContext | A new composition container. |
CreateConventionsBuilder()
Factory method for creating the conventions builder.
Declaration
protected abstract IConventionsBuilder CreateConventionsBuilder()
Returns
Type | Description |
---|---|
IConventionsBuilder | A newly created conventions builder. |
GetCompositionAssemblies()
Gets the composition assemblies.
Declaration
protected IEnumerable<Assembly> GetCompositionAssemblies()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | An enumeration of assemblies used for composition. |
GetConventionAssemblies(IEnumerable<Assembly>)
Gets the convention assemblies.
Declaration
protected IEnumerable<Assembly> GetConventionAssemblies(IEnumerable<Assembly> fallbackAssemblies)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | fallbackAssemblies | The fallback assemblies, used if no convention assemblies are provided. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | An enumeration of assemblies used for conventions. |
GetConventions(IEnumerable<Assembly>, IList<Type>)
Gets the convention builder.
Declaration
protected virtual IConventionsBuilder GetConventions(IEnumerable<Assembly> assemblies, IList<Type> parts)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | The assemblies containing the conventions. |
System.Collections.Generic.IList<System.Type> | parts | The parts. |
Returns
Type | Description |
---|---|
IConventionsBuilder | The convention builder. |
GetSettings()
Gets the composition settings.
Declaration
protected virtual CompositionSettings GetSettings()
Returns
Type | Description |
---|---|
CompositionSettings | The composition settings. |
WithAssemblies(IEnumerable<Assembly>)
Adds the assemblies containing the composition parts.
Declaration
public virtual TBuilder WithAssemblies(IEnumerable<Assembly> assemblies)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | The composition assemblies. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Remarks
Can be used multiple times, the provided assemblies are added to the existing ones.
WithAssembly(Assembly)
Adds the assembly containing the composition parts.
Declaration
public virtual TBuilder WithAssembly(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The composition assembly. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Remarks
Can be used multiple times, the provided assembly is added to the existing ones.
WithConventionAssemblies(IEnumerable<Assembly>)
Adds the assemblies containing the conventions.
Declaration
public virtual TBuilder WithConventionAssemblies(IEnumerable<Assembly> assemblies)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | The convention assemblies. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Remarks
Can be used multiple times, the provided assemblies are added to the existing ones.
WithConventionAssembly(Assembly)
Adds the assembly containing the conventions.
Declaration
public virtual TBuilder WithConventionAssembly(Assembly assembly)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.Assembly | assembly | The convention assembly. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Remarks
Can be used multiple times, the provided assembly is added to the existing ones.
WithConventions(IConventionsBuilder)
Sets the composition conventions.
Declaration
public virtual TBuilder WithConventions(IConventionsBuilder conventions)
Parameters
Type | Name | Description |
---|---|---|
IConventionsBuilder | conventions | The conventions. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
WithConventionsRegistrar(IConventionsRegistrar)
Adds the export provider.
Declaration
public virtual TBuilder WithConventionsRegistrar(IConventionsRegistrar conventionsRegistrar)
Parameters
Type | Name | Description |
---|---|---|
IConventionsRegistrar | conventionsRegistrar | The conventions registrar. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Remarks
Can be used multiple times, the factories are added to the existing ones.
WithFactory<TContract>(Func<TContract>, Boolean, Boolean)
Adds the factory export.
Declaration
public virtual TBuilder WithFactory<TContract>(Func<TContract> factory, bool isSingleton = false, bool allowMultiple = false)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TContract> | factory | The factory. |
System.Boolean | isSingleton | If set to |
System.Boolean | allowMultiple | Indicates whether multiple registrations are allowed. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Type Parameters
Name | Description |
---|---|
TContract | The type of the contract. |
Remarks
Can be used multiple times, the factories are added to the existing ones.
WithPart(Type)
Adds the composition parts.
Declaration
public virtual TBuilder WithPart(Type part)
Parameters
Type | Name | Description |
---|---|---|
System.Type | part | The composition part. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Remarks
Can be used multiple times, the provided part is added to the existing ones.
WithParts(IEnumerable<Type>)
Adds the composition parts.
Declaration
public virtual TBuilder WithParts(IEnumerable<Type> parts)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Type> | parts | The parts. |
Returns
Type | Description |
---|---|
TBuilder | This builder. |
Remarks
Can be used multiple times, the provided parts are added to the existing ones.
WithRegistration(IAppServiceInfo[])
Adds the registrations.
Declaration
public virtual TBuilder WithRegistration(params IAppServiceInfo[] registrations)
Parameters
Type | Name | Description |
---|---|---|
IAppServiceInfo[] | registrations | A variable-length parameters list containing registrations. |
Returns
Type | Description |
---|---|
TBuilder | A TBuilder. |