也许我错过了描述这一点的正确语言,但是我正在尝试使用一种既有方法,将BO与当前通过的BO不同。
我想应该是这样的:
public override SetInsurance(BusinessObjects.Utilities.LandViewer Viewer_land || BusinessObjects.Utilities.SeaViewer Viewer_sea, DataTable patient, int InsurancePriority)
{
}
感谢任何帮助,因为它可能不存在。
* //请注意,这些BO的相似度为95%,但在我们的代码库中,将它们组合不是一个选项。
您应该采用相似度为95%的位(或至少要在此方法和其他可以使用这两种类型的方法中使用的位),并将它们放入接口中,例如interface IViewer
。使LandViewer
和SeaViewer
都实现该接口,并采用该方法,例如:
interface IViewer {
string Name {get;set;}
}
class LandViewer: IViewer {
public string Name {get;set;}
public int SomeValue;
}
class SeaViewer: IViewer {
public string Name {get;set;}
public string SomeOtherValue;
}
public override SetInsurance(IViewer viewer, DataTable patient, int InsurancePriority) {
Console.WriteLine(viewer.Name); //.Name is accessible as it's part of the 95%
// .SomeValue and .SomeOtherValue are not accessible, because they're not part of the 95%
}