public void Intercept(IInvocation invocation)
{
var methodName = invocation.Method.Name;
if (methodName.StartsWith("set_"))
{
var propertyName = methodName.Substring(4);
properties[propertyName] = invocation.Arguments[0];
return;
}
if (methodName.StartsWith("get_"))
{
var propertyName = methodName.Substring(4);
var value = properties[propertyName];
invocation.ReturnValue = value;
return;
}
throw new ArgumentException("Only works with properties");
}
}