You should be able to achieve this by reducing the XML to this.
You should be able to achieve this by reducing the XML to this: MyDatabaseName and then make sure your registration registers the repository under the right key/id - e.g. Like this: container. Register(AllTypes(...). Configure(c => c.
Named(c.Implementation. Name))) where all keys will be set to the short name of each concrete type. Please note that this naming scheme might not be appropriate for you, so you should probably adapt the c.
Named(...) to whatever you deem right for your use case. Just make sure that the registration key for your repository matches that if the id attribute in the XML.
I'll give that a shot, thanks! – Lirik Apr 19 at 12:05 I still get an exception: "the SqlUsersRepository is waiting for the following keys... Keys (components with specific keys) - databaseName which was not registered. " So the part I don't get is how do I determine the registration key for the repository (and how do I ensure that it matches the id attribute?
– Lirik Apr 21 at 0:16 My best guess at the "(...) waiting for the following keys (...)" error is that you forgot to pass an XmlInterpreter to Windsor upon instantiation, like so: var container = new WindsorContainer(new XmlInterpreter()) – mookid8000 Apr 26 at 7:44 Regarding naming, it's probably best to explicitly name the repository in the container – mookid8000 Apr 26 at 7:48.
DependsOn the way you've done it = the parameter named "databaseName" has a component dependency with a key "MyDatabaseName". You want to do a . Parameters(ForKey.
Named("databasename"). Value(ConfigurationManager. ConnectionStrings"MyDatabasename".
ConnectionString)).LifeStyle.Transient. ...
I want to avoid specifically naming the database name in the program... I can have a "custom" entry in the Web. Config which tells me the database name. With CastleWindsor, that custom entry was supposed to be in the ... section of the Web.
Config, but it's not working. I guess I'll just have to read it myself, without relying on CastleWindsor to do it. – Lirik Apr 22 at 4:11.
I figured out the dependency exception... the issue was that my repositories are in a different assembly, so I had to rig the installation a bit: public class RepositoriesInstaller : IWindsorInstaller { public void Install(IWindsorContainer container, IConfigurationStore store) { foreach (AssemblyName name in Assembly. GetExecutingAssembly(). GetReferencedAssemblies()) { Assembly asm = Assembly.
Load(name); container. Register(AllTypes. FromAssemblyNamed(asm.
FullName) . Where(Component. IsInSameNamespaceAs()) .WithService.
DefaultInterface() . Configure(c => c.LifeStyle. Transient .
DependsOn(new { databaseName = "MyDatabaseName" }))); } container. Register(AllTypes. FromThisAssembly() .
Where(Component. IsInSameNamespaceAs()) .WithService. DefaultInterface() .
Configure(c => c.LifeStyle. Transient . DependsOn(new { databaseName = "MyDatabaseName" }))); } } Still trying to figure out how to get the database name from the castle section of the Web.
Config though.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.