mirror of https://github.com/AMT-Cheif/Stylet.git
Register IContainer with the builder
This commit is contained in:
parent
3ec42446b4
commit
52b8da8ab6
|
@ -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);
|
||||
|
|
|
@ -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>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue