Skip to content
Mike Evans-Larah By Mike Evans-Larah Software Engineer III
Introducing endjin composition framework 2.0 : Part 3 - Using the content factory

As I explained in this post, the framework provides a set of installers for registering components against interfaces in the container.

Another powerful tool in the composition framework is the ContentFactory. This provides methods for registering and getting content based on a contentType string. When getting content, if the contentType is not found in the container, it will try to fallback using substrings of contentType by progressively removing sections after a .

Azure Weekly is a summary of the week's top Microsoft Azure news from AI to Availability Zones. Keep on top of all the latest Azure developments!

As an example, we might have some serializers that inherit from ISerializer.

We can create a new SerializerFactory that inherits from ContentFactory.

Then we use a custom installer to register the factory as a singleton, and also to register our default content (i.e. the serializers).

We are now able to use the SerializerFactory.GetContentFor(string contentType) method to retrieve our serializers by the name we registered them with:

  • SerializerFactory.GetContentFor("Foo") will return FooSerializer
  • SerializerFactory.GetContentFor("Foo.Bar") will return FooBarSerializer
  • SerializerFactory.GetContentFor("Foo.Bar.Baz") will fallback to contentType of "Foo.Bar" and return FooBarSerializer
Power BI Weekly is a collation of the week's top news and articles from the Power BI ecosystem, all presented to you in one, handy newsletter!

In the next post I'll show you how to get set up with endjin composition framework in an MVC4 / WebAPI application.

@MikeLarah

Mike Evans-Larah

Software Engineer III

Mike Evans-Larah

Mike is a Software Engineer at endjin with over a decade of experience in solving business problems with technology. He has worked on a wide range of projects for clients across industries such as financial services, recruitment, and retail, with a strong focus on Azure technologies.