I've been struggling to find anything online, so I thought I'd see if anyone else knows how to sort this little issue I'm having.
I've got a scenario where I want to create a proxy object so that various other interfaces can be added to the same object. So far, I've not had any issues with this. One of my other requirements is to be able to set an attribute on the proxy-generated class.
I've been able to do this successfully using Castle DynmaicProxy manually, using something along the lines of:
var serviceOptions = new ProxyGenerationOptions();
// Create MyAttribute
var args = new object[] { "SomeName" };
var constructorTypes = new[] { typeof(String) };
var constructorInfo = typeof(MyAttribute).GetConstructor(constructorTypes);
var attributeBuilder = new CustomAttributeBuilder(constructorInfo, args);
serviceOptions.AdditionalAttributes.Add(attributeBuilder);
However, I'm using windsor to resolve my dependencies through injection. Windsor does provide some proxy options, such as:
configurer.Proxy.AdditionalInterfaces(interfaces);
configurer.Proxy.MixIns(r => r.Component(type));
But it does not seem to offer options for custom attributes. Does anyone know how this can be achieved? Many thanks.