I have a base class and multiple derived classes:
public class Camera
{
}
public class CameraManufacturerA : Camera
{
}
public class CameraManufacturerB : Camera
{
}
public class CameraManufacturerC : Camera
{
}
Now I want to add features that extend the base functionality:
public class CameraFeatureA : Camera
{
public int FeatureProperty { get; set; }
public bool RunFeatureA();
}
These features only make sense for certain child classes, I aim for something like this:
public class MyCamera : CameraManufacturerA, CameraFeatureB, CameraFeatureD
{
}
I know, exactly like this, it won't be possible (for good reasons). I spent a lot of time trying to find something similar, but could not find a solution that comes close. Any Ideas?
One more info: the combined class (MyCamera) will be used in a kind of code editor that uses reflection. That is why it is important that properties of the child classes are indeed properties. But I could work with a "hacky" solution using reflection or dynamic class creation. I only need the final combined class at runtime.
CameraManufacturerA,CameraFeatureB,CameraFeatureD(Probably typo? Should beCameraManufacturerB,CameraManufacturerC?). Without actual context, we can't know what you are trying to achieve.class MyCamera { CameraFeatureA a; CameraFeatureB b; CameraFeatureC c; }If you need a combined class, why do you need inheritance?Cameraclass. I suspect it would be better to have aCameraFeatureclass (or possibly anICameraFeatureinterface) and then makeCamerahave a list ofCameraFeaturesfor features that camera supports.