void DoSomething(bool callOtherService);
void DoSomethingElse(bool callOtherService);
class FooService : IFooService
protected IBarService _bar;
public void DoSomething(bool callOtherService)
Console.WriteLine("Hello world. I am Foo.");
_bar.DoSomethingElse(false);
class BarService : IBarService
protected IFooService _foo;
public void DoSomethingElse(bool callOtherService)
Console.WriteLine("Hello world. I am Bar.");
protected readonly IFooService _foo;
protected readonly IBarService _bar;
public Application(IFooService foo, IBarService bar)
_bar.DoSomethingElse(true);
public static IContainer CompositionRoot()
var foo = new FooService();
var bar = new BarService();
var builder = new ContainerBuilder();
builder.RegisterInstance<IFooService>( foo );
builder.RegisterInstance<IBarService>( bar );
builder.RegisterType<Application>().SingleInstance();
public static void Main()
CompositionRoot().Resolve<Application>().Run();