public interface ISelectable
{
bool Selected { get; set; }
}
public class Selectable : ISelectable
{
#region ISelectable Members
public virtual bool Selected { get; set; }
#endregion
}
[Behavior(0, typeof(ISelectable))]
public class SelectableBehavior : IInterceptor
{
#region IInterceptor Members
public void Intercept(IInvocation invocation)
{
if (invocation.Method.DeclaringType.Equals(typeof(ISelectable)))
{
if (invocation.Method.Name.Equals("get_Selected"))
{
invocation.ReturnValue = (bool)invocation.Arguments[0];
}
invocation.Proceed();
//if ("set_Selected".Equals(invocation.Method.Name))
//{
// invocation.Method.Invoke(invocation.InvocationTarget, invocation.Arguments);
//}
}
else
{
invocation.Proceed();
}
}
#endregion
}
i have the above interface, class and Interceptor and the following class
public class Entity
{}
and i have register the Interceptor via Castle container
Entity e = ServiceLocator.Current.GetInstance<Entity>();
when trying to
((ISelectable) a).Selected = true;
I get the following error
System.NotImplementedException : This is a DynamicProxy2 error:
the interceptor attempted to 'Proceed' for method 'Void set_Selected(Boolean)'
which has no target. When calling method without target there is no implementation
to 'proceed' to and it is the responsibility of the interceptor to mimic the
implementation (set return value, out arguments etc)
Please help