Created
December 31, 2009 07:49
-
-
Save kkozmic/266661 to your computer and use it in GitHub Desktop.
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
namespace ConsoleApplication2 | |
{ | |
using System.Diagnostics; | |
using Castle.MicroKernel.Registration; | |
using Castle.Windsor; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var container = new WindsorContainer().Register( | |
Component.For<Foo>().LifeStyle.Transient, | |
Component.For<Bar>().LifeStyle.Transient, | |
Component.For<Baz>().LifeStyle.Registration); | |
var foo = container.Resolve<Foo>(); | |
Debug.Assert(ReferenceEquals(foo.Baz, foo.Bar.Baz)); | |
} | |
} | |
public class Foo | |
{ | |
private readonly Bar bar; | |
private readonly Baz baz; | |
public Foo(Bar bar, Baz baz) | |
{ | |
this.bar = bar; | |
this.baz = baz; | |
} | |
public Bar Bar | |
{ | |
get { return bar; } | |
} | |
public Baz Baz | |
{ | |
get { return baz; } | |
} | |
} | |
public class Bar | |
{ | |
private readonly Baz baz; | |
public Bar(Baz baz) | |
{ | |
this.baz = baz; | |
} | |
public Baz Baz | |
{ | |
get { return baz; } | |
} | |
} | |
public class Baz | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment