好的,这需要先进行一些设置。
public interface IPolicyObjectAdapter
{
PolicyImage GetPolicyImage(BridgePolicy policy);
}
public class BridgePolicyAdapter : IPolicyObjectAdapter
{
protected virtual PolicyImage GetPolicyImage(BridgePolicy policy)
{
AddPolicyInformation(policy);
}
protected virtual void AddPolicyInformation(BridgePolicy policy)
{
//does stuff
}
}
public class HSPolicyAdapter : BridgePolicyAdapter, IPolicyObjectAdapter
{
protected override void AddPolicyInformation(BridgePolicy policy)
{
base.AddPolicyInformation(policy);
//does more stuff
}
}
当我执行以下代码时,我希望代码进入 HSPolicyAdapter 的 AddPolicyInformation 方法。但它永远不会。它直接进入 BridgePolicyAdapters AddPolicyInformation 方法。
IPolicyObjectAdapter Adapter = null;
Adapter = new HSPolicyAdapter();
PolicyImage image = Adapter.GetPolicyImage(policy);
我确信我错过了一些如此明显会伤害的东西,但我的大脑现在无法正常工作。我错过了什么?