Endjin - Home

Introducing endjin composition framework 2.0 : Part 2 – Getting Started

by Mike Larah

In the last post I introduced v2.0 of our open source, composition framework. In this post, I’m going to cover a quick example of how to get started with the basics of the endjin composition framework.

Firstly, we define an interface for some type

Then, we create a concrete type for our interface

Now we can use one the composition framework’s convention based installers. For instance we could use the namespace installer, to install all types in a given namespace into the container.

The namespace installer will register types against their Default interface – where the default interface is the interface that follows the naming convention I + [my specific name] + [service name] (e.g. the default interface for class FooBarService : IFooService, IFooBarService is IFooBarService)

Most of the convention-based installers will install the concrete type into the container as Transient by default, but we can explicit specify the lifestyle using [Singleton] and [Transient] attributes.

See the Installers page on the GitHub wiki for a complete list of all the installers included in the framework, and explanations of how they work.

Next step is to initialize the container within our application’s start-up code. This is done using the Bootstrapper appropriate for whichever framework we are using, which will locate the installers in our assemblies and install the types they find into the container.



.NET 4.0/4.5

You can now use the static ApplicationServiceLocator.Container for resolving your root types.

In the next post, I’ll go over how to use the ContentFactory for registering content with custom names.


About the author

Mike is a Software Engineer at endjin with 4 years experience in solving technology problems for clients. He is a certified Microsoft Cloud Platform developer, and has experience building solutions utilising much of the Azure ecosystem.