Reputation: 1
Maybe I am missing the correct language to describe this, but I am trying to utilize a pre-existing method with a different BO than currently passed.
I guess it would be something like:
public override SetInsurance(BusinessObjects.Utilities.LandViewer Viewer_land || BusinessObjects.Utilities.SeaViewer Viewer_sea, DataTable patient, int InsurancePriority)
{
}
Any help is appreciated as this might just not exist.
*//Note that these BOs are 95 percent similar but combining them is not an option in our codebase.
Upvotes: 0
Views: 73
Reputation: 32202
You should take the bits that are 95% similar (or at least the bits you'd like to use in this and other methods that can work with either type), and put them in an interface, say interface IViewer
. Have both LandViewer
and SeaViewer
implement that interface, and have the method take it, eg:
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%
}
Upvotes: 2