I know that CSLA can be used with Unity via the BuildUp method, however this does does not appear to be any equivalent capability with Castle Windsor. Has anyone figured out a way to combine these two?
You can write your own version of BuildUp:
public static void BuildUp(object target)
{
var type = target.GetType();
foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
if (property.CanWrite && Container.Kernel.HasComponent(property.PropertyType))
{
var value = Container.Resolve(property.PropertyType);
try
{
property.SetValue(target, value, null);
}
catch (Exception ex)
{
var message = string.Format("Error setting property {0} on type {1}, See inner exception for more information.", property.Name, type.FullName);
throw new ComponentActivatorException(message, ex);
}
}
}
}
where Container is the Castle Windsor container.
Copyright (c) Marimer LLC