I have some legacy code to be refactored. At first, I have a child class interface: IChild
. and some classes that implements that interface, like: ChildType1 : IChild
, ChildType2 : IChild
and ChildType3 : IChild
.
The parent has the child types properties, and each time only one of them get initialized example if ChildType1
has value then ChildType2
and ChildType3
are null
:
class Parent
{
public ChildType1 Type1 { get; set; }
public ChildType2 Type2 { get; set; }
public ChildType3 Type3 { get; set; }
//...
}
The IChild
holds some important property Enum:
public interface IChild
{
ImportantEnum MyEnum { get; set; }
//
}
My question: regarding the fact I do not know which one of the Types are initiated, what is the best way to make the child MyEnum
property to be available through the parent api?
I'm open for refactoring.
Aucun commentaire:
Enregistrer un commentaire