Class AppBootstrapper
Represents the bootstrapper for the application.
Inherited Members
Namespace: Gemini
Assembly: Gemini.dll
Syntax
public class AppBootstrapper : BootstrapperBase
Remarks
This bootstrapper uses the Managed Extensibility Framework to compose the objects.
Constructors
AppBootstrapper()
Declaration
public AppBootstrapper()
Properties
Container
Gets or sets the MEF composition container. Set by Configure().
Declaration
public CompositionContainer Container { get; protected set; }
Property Value
Type | Description |
---|---|
System.ComponentModel.Composition.Hosting.CompositionContainer |
Methods
BindServices(CompositionBatch)
Adds additional exports to the MEF composition.
Declaration
protected virtual void BindServices(CompositionBatch batch)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.Composition.Hosting.CompositionBatch | batch | Batch where the exports should be add. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
BuildUp(Object)
Defines the Caliburn.Micro.IoC.BuildUp method. Injects dependencies to instance
that are exported.
Declaration
protected override void BuildUp(object instance)
Parameters
Type | Name | Description |
---|---|---|
Object | instance | The instance to perform injection on. |
Overrides
Remarks
This method calls the System.ComponentModel.Composition.AttributedModelServices.SatisfyImportsOnce(System.ComponentModel.Composition.ICompositionService,System.Object) method.
Examples
private class ItemWithDependecies
{
[Import]
private IMainWindow _window;
}
var instance = new ItemWithDependecies();
// the IoC injects now the exported IMainWindow instance to the object.
IoC.BuildUp(instance)
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown if Container is not set. |
See Also
Configure()
Configures and sets up the MEF containers.
Declaration
protected override void Configure()
Overrides
Remarks
The MEF exports are prioritized depending on its containing assembly:
- Assemblies provided by SelectAssemblies() (high priority)
- Assemblies provided by neither 1 nor 3 (medium priority)
- The Gemini assembly (low priority)
GetAllInstances(Type)
Gets all instances of a particular type.
Declaration
protected override IEnumerable<object> GetAllInstances(Type serviceType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | serviceType | Contract type. |
Returns
Type | Description |
---|---|
IEnumerable<Object> | All instances exported with the |
Overrides
GetInstance(Type, String)
Gets a instance by contract type and key.
Declaration
protected override object GetInstance(Type serviceType, string key)
Parameters
Type | Name | Description |
---|---|---|
System.Type | serviceType | Contract type. |
String | key | Contract key or null. |
Returns
Type | Description |
---|---|
Object | The instance exported with the contracts. |
Overrides
Exceptions
Type | Condition |
---|---|
System.Collections.Generic.KeyNotFoundException | Thrown if no instance could be located. |
OnStartup(Object, StartupEventArgs)
Executed after the application starts.
Declaration
protected override void OnStartup(object sender, StartupEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
Object | sender | The sender. |
StartupEventArgs | e | Startup event arguments. |
Overrides
Remarks
Displays the imported IMainWindow instance.
PreInitialize()
Preinitializes the framework. This method is called before the Caliburn.Micro.BootstrapperBase.Initialize() method is called.
Declaration
protected virtual void PreInitialize()
SelectAssemblies()
Selects the priority assemblies.
Declaration
protected override IEnumerable<Assembly> SelectAssemblies()
Returns
Type | Description |
---|---|
IEnumerable<System.Reflection.Assembly> | The high priority assemblies. |
Overrides
Remarks
This method returns by default the System.Reflection.Assembly.GetEntryAssembly. Override this method to prioritize other assemblies.