Get a Service by ServiceType

Requesting the default configured object of a service type is done through the IContainer.GetInstance() method shown below:

[Fact]
public void get_the_default_instance()
{
    var container = new Container(x =>
    {
        x.For<IWidget>().Use<AWidget>();
    });

    container.GetInstance<IWidget>()
        .ShouldBeOfType<AWidget>();

    // or

    container.GetInstance(typeof(IWidget))
        .ShouldBeOfType<AWidget>();
}

snippet source | anchor

[Fact]
public void get_the_default_instance()
{
    var container = new Container(x => { x.For<IWidget>().Use<AWidget>(); });

    container.GetInstance<IWidget>()
        .ShouldBeOfType<AWidget>();

    // or

    container.GetInstance(typeof(IWidget))
        .ShouldBeOfType<AWidget>();
}

snippet source | anchor