Implementing SimpleInjector in Liara.

Feb 21, 2014 at 4:47 PM

I've started up with an Open Source Web Framework Project called Liara, where everything is just a message handler, including routing resolution, formatting, route invocation etc, basically making everything swap in and swap out, as required.

If interested, you may check it out at:

I've completed most of the basic feature-set, but for quick prototyping, I used LightInject as the container. I'm yet to implement a factory for the class (LiaraModule) invocation, and currently uses LightInject's service name key for resolving the route classes. That's an anti-pattern for just prototyping which I'm yet to rewrite.

But ultimately, the idea is that it every single core service itself is registered, and used from the container, so that the framework itself is fully configurable just through the service container.

But I'm still trying to solve an architectural issue of how to approach it in order to have a container that will service the core services, as well as additional set of "request-time" services just during the request scope (Similar to how NancyFx does.)

Currently the model I've followed is similar to WebApi, where you have a dependency scope (but it has its multi-threading problems) I'm looking for the best approach to have a the base container services, and have additional services just for a scope on top it, and also make sure its thread-safe.

I'd appreciate any thoughts. :)

Feb 25, 2014 at 5:02 PM

we're pretty busy working on SimpleInjector 2.5 at present and it's hard for us to make any meaningful observations on your project without taking the time to properly understand all you have done - and sadly it's not time any of us have.

If you have more specific questions that we can help you with on your journey from LightInject to SimpleInjector then please ask them here but we're really not able to review your code for you at this time.


Marked as answer by dot_NET_Junkie on 3/2/2014 at 11:19 AM
Feb 25, 2014 at 11:08 PM
Hello Peter,

I appreciate the reply. That's understandable. At the moment, I more concerned about the design itself, before I plug SimpleInjector into it. I believe I do have a design worked out, though yet to be implement that solves what I'm looking for now.

PS: Looking forward to 2.5, especially the container scoping to flow through the execution context.

Feb 26, 2014 at 11:58 AM

I'm running the beta and it's working well, all in all the new release is looking pretty nifty! :-)
Feb 26, 2014 at 6:22 PM
>> PS: Looking forward to 2.5, especially the container scoping to flow through the execution context.

Well, we just pushed 2.5.0-beta2 to NuGet and this beta now contains a package to work with async/await, called the Execution Context Scoping Extensions.

This package contains the ExecutionContextScopeLifestyle, which allows defining an explicit scope that works just as the Lifetime Scope, but flows with asynchronous methods. Example:
// using SimpleInjector.Extensions.ExecutionContextScoping;

async Task Handle(ProcessContentCommand command)
    using (this.container.BeginExecutionContextScope()) {
        HttpClient client = new HttpClient();
        string content = await client.GetStringAsync(command.Url);
        await ProcessContent(content);
But if you're using Web API, you can use the WebApiRequestLifestyle as well (which uses the BeginExecutionContextScope in the background) and when using the Web API integration quick start package, everything is wired for you and you're good to go.

This beta is of very high quality; you should definitely check it out!