-
-
Save gimmi/1223741 to your computer and use it in GitHub Desktop.
Windsor 3 scoped disposing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void Should_resolve_lazy_components() | |
{ | |
var container = new WindsorContainer(); | |
container.Register(Component.For<LazyOfTComponentLoader>()); | |
container.Register(Component.For<A>().LifeStyle.Transient); | |
var a = container.Resolve<A>(); // Ok | |
var lazyA = container.Resolve<Lazy<A>>(); // Fail | |
} | |
public class A | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void Should_release_scoped_component_when_scope_is_disposed2() | |
{ | |
var container = new WindsorContainer(); | |
container.Register(Component.For<A>().LifestyleScoped()); | |
A a; | |
using(container.BeginScope()) | |
{ | |
a = container.Resolve<A>(); | |
} | |
Assert.IsTrue(a.Disposed); | |
} | |
public class A : IDisposable | |
{ | |
public bool Disposed; | |
public void Dispose() | |
{ | |
Disposed = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment