Register IContainer with the builder

This commit is contained in:
Antony Male 2015-02-23 10:47:56 +00:00
parent 3ec42446b4
commit 52b8da8ab6
2 changed files with 11 additions and 0 deletions

View File

@ -300,6 +300,9 @@ namespace StyletIoC
var container = new Container();
// Just in case they want it
this.Bind<IContainer>().ToInstance(container).AsWeakBinding();
// For each TypeKey, we remove any weak bindings if there are any strong bindings
var groups = this.bindings.GroupBy(x => new { Key = x.Key, Type = x.ServiceType });
var filtered = groups.SelectMany(group => group.Any(x => !x.IsWeak) ? group.Where(x => !x.IsWeak) : group);

View File

@ -289,7 +289,15 @@ namespace StyletUnitTests
Assert.Throws<ObjectDisposedException>(() => ioc.Get(typeof(C1)));
Assert.Throws<ObjectDisposedException>(() => ioc.GetTypeOrAll<C1>());
Assert.Throws<ObjectDisposedException>(() => ioc.GetTypeOrAll(typeof(C1)));
}
[Test]
public void IContainerIsAvailable()
{
var builder = new StyletIoCBuilder();
var ioc = builder.BuildContainer();
Assert.AreEqual(ioc, ioc.Get<IContainer>());
}
}
}