Skip to content
On this page

Changing Configuration at Runtime

WARNING

Don't do this, you've been warned.

The Lamar team respectfully recommends that you don't do this, but this functionality is here because we had to have this for Jasper's integration with ASP.Net Core. Please note that this should only be used additively. Unlike StructureMap, Lamar will not rewrite build plans for existing registrations to accommodate changes here.

cs
[Fact]
public void add_all_new_services()
{
    var container = new Container(_ => { _.AddTransient<IWidget, RedWidget>(); });

    container.Configure(_ => _.AddTransient<IService, WhateverService>());

    container.GetInstance<IService>()
        .ShouldBeOfType<WhateverService>();
}

snippet source | anchor