1 class Program 2 { 3 static void Main(string[] args) 4 { 5 var container = new WindsorContainer(); 6 container.Install(FromAssembly.This()); 7 8 var king = container.Resolve<IKing>("King1"); 9 king.SayHello(); 10 var king2 = container.Resolve<IKing>("King2"); 11 king2.SayHello(); 12 Console.Read(); 13 14 } 15 } 16 public class RepositoriesInstaller : IWindsorInstaller 17 { 18 public void Install(IWindsorContainer container, IConfigurationStore store) 19 { 20 //container.Register(Classes.FromThisAssembly() 21 // .Where(Component.IsInSameNamespaceAs<King>()) 22 // .WithService.DefaultInterfaces() 23 // .LifestyleTransient()); 24 //container.Register(Classes.FromThisAssembly() 25 // .Where(Component.IsInSameNamespaceAs<King2>()) 26 // .WithService.DefaultInterfaces() 27 // .LifestyleTransient()); 28 container.Register(Component.For(typeof(IKing)) 29 .ImplementedBy(typeof(King1)) 30 .Named("King1").LifestyleTransient()); 31 container.Register(Component.For(typeof (IKing)) 32 .ImplementedBy(typeof (King2)) 33 .Named("King2").LifestyleTransient()); 34 } 35 } 36 37 public interface IKing 38 { 39 void SayHello(); 40 } 41 42 public class King1 : IKing 43 { 44 public void SayHello() 45 { 46 Console.WriteLine("Hello i am the first king1"); 47 } 48 } 49 50 51 public class King2 : IKing 52 { 53 public void SayHello() 54 { 55 Console.WriteLine("Hello i am the first king2"); 56 } 57 }
https://github.com/castleproject/Windsor/blob/master/docs/README.md