Hi
In Windsor 2.5.3, the code below worked fine, however in Windsor 3.0
RC1 this throws the following exception:
Unable to cast object of type 'Castle.Proxies.IMyServiceProxy' to type
'IService'.
Is this a change in 3.0 ??
TIA
Søren
public class MyInterceptor : IInterceptor
{
public void Intercept(IInvocation invocation)
{
invocation.Proceed();
}
}
public class InterceptorSelector : IModelInterceptorsSelector
{
public bool HasInterceptors(ComponentModel model)
{
return
typeof(IMyService).IsAssignableFrom(model.Implementation);
}
public InterceptorReference[]
SelectInterceptors(ComponentModel model, InterceptorReference[]
interceptors)
{
if
(typeof(IMyService).IsAssignableFrom(model.Implementation))
{
var tmp = new List<InterceptorReference>
{ InterceptorReference.ForType<MyInterceptor>() };
return tmp.ToArray();
}
return interceptors;
}
}
public interface IService
{
}
public interface IMyService
{
string Helloworld();
}
public abstract class ServiceBase : IService
{
}
public class MyServiceClass : ServiceBase, IMyService
{
public string Helloworld()
{
return "Hello world";
}
}
class Program
{
static void Main(string[] args)
{
var container = new WindsorContainer();
container.Kernel.ProxyFactory.AddInterceptorSelector(new
InterceptorSelector());
container.Register(Component.For<MyInterceptor>());
container.Register(Component.For<IMyService>().ImplementedBy<MyServiceClass>().Named("testService"));
var sut = container.Resolve<IService>("testService");
var res = ((IMyService)sut).Helloworld();
}
}
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.