public void Intercept(IInvocation invocation) { IStorageNode master = invocation.InvocationTarget as IStorageNode; if (master.IsDead) { IChangeProxyTarget cpt = invocation as IChangeProxyTarget; // 将补代理对象master更换为slave cpt.ChangeProxyTarget(_slave); // 测试中恢复master状态,以便看到随后调用仍然使用master这一效果 master.IsDead = false; } invocation.Proceed(); }