Answer the question
In order to leave comments, you need to log in
Registering dependencies from other assemblies in CastleWindsor?
I use the latest version of CastleWindsor as an IoC container in my project. Project under MVC4, SOA is used. The project already at the alpha testing stage has a lot of functionality and code, for further extensibility, many parts of the code are separated not only for different projects, but even for different solutions.
Thus, when registering the dependencies of UI solutions, you have to pull these dependencies from third-party assemblies. Are there any solutions that would be better than mine?
My Solution
There is a static class in the CoreFramework of the application
public static class AssemblyNamesRepository
{
private static readonly string[] assemblyNames = new[]
{
"Core", "BusinessObjects", "UserServices",
"ModuleServices", "CharacterServices",
"RoomServices", "ReaderServices", "CommentServices",
"PostServices", "AttributesServices", "BaseSite"
};
public static IEnumerable<string> SelectAll()
{
return assemblyNames;
}
}
foreach (var assemblyName in AssemblyNamesRepository.SelectAll())
container.Register(
Types.FromAssemblyNamed(assemblyName)
.Where(t => t.IsClass)
.Configure(t => t.LifestylePerWebRequest())
.WithService.AllInterfaces());
Answer the question
In order to leave comments, you need to log in
I solved the problem through the xml-file with the topology settings. One way or another, I had to bind each service to its port, and describe a few more little things for each service. At the same time I decided to store the name of the assembly in this file. Now, at the start of the application, I simply read these AssemblyNames from the file, and then I do everything the same way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question