Table of Contents

Class AppBootstrapper

Namespace
Gemini
Assembly
Gemini.dll

Represents the bootstrapper for the application.

public class AppBootstrapper : BootstrapperBase
Inheritance
BootstrapperBase
AppBootstrapper
Derived
Inherited Members
BootstrapperBase.Initialize()
BootstrapperBase.StartDesignTime()
BootstrapperBase.StartRuntime()
BootstrapperBase.PrepareApplication()
BootstrapperBase.Application

Remarks

This bootstrapper uses the Managed Extensibility Framework to compose the objects.

Constructors

AppBootstrapper()

public AppBootstrapper()

Properties

Container

Gets or sets the MEF composition container. Set by Configure().

public CompositionContainer Container { get; protected set; }

Property Value

CompositionContainer

Methods

BindServices(CompositionBatch)

Adds additional exports to the MEF composition.

protected virtual void BindServices(CompositionBatch batch)

Parameters

batch CompositionBatch

Batch where the exports should be add.

Exceptions

ArgumentNullException

Thrown if batch is null.

BuildUp(object)

Defines the Caliburn.Micro.IoC.BuildUp method. Injects dependencies to instance that are exported.

protected override void BuildUp(object instance)

Parameters

instance object

The instance to perform injection on.

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)

Remarks

Exceptions

InvalidOperationException

Thrown if Container is not set.

See Also

Configure()

Configures and sets up the MEF containers.

protected override void Configure()

Remarks

The MEF exports are prioritized depending on its containing assembly:

  1. Assemblies provided by SelectAssemblies() (high priority)
  2. Assemblies provided by neither 1 nor 3 (medium priority)
  3. The Gemini assembly (low priority)

GetAllInstances(Type)

Gets all instances of a particular type.

protected override IEnumerable<object> GetAllInstances(Type serviceType)

Parameters

serviceType Type

Contract type.

Returns

IEnumerable<object>

All instances exported with the serviceType as contract.

GetInstance(Type, string)

Gets a instance by contract type and key.

protected override object GetInstance(Type serviceType, string key)

Parameters

serviceType Type

Contract type.

key string

Contract key or null.

Returns

object

The instance exported with the contracts.

Exceptions

KeyNotFoundException

Thrown if no instance could be located.

OnStartup(object, StartupEventArgs)

Executed after the application starts.

protected override void OnStartup(object sender, StartupEventArgs e)

Parameters

sender object

The sender.

e StartupEventArgs

Startup event arguments.

Remarks

Displays the imported IMainWindow instance.

PreInitialize()

Preinitializes the framework. This method is called before the Caliburn.Micro.BootstrapperBase.Initialize() method is called.

protected virtual void PreInitialize()

SelectAssemblies()

Selects the priority assemblies.

protected override IEnumerable<Assembly> SelectAssemblies()

Returns

IEnumerable<Assembly>

The high priority assemblies.

Remarks

This method returns by default the entry assembly. Override this method to prioritize other assemblies.

See Also