I'm receiving an object of class Foo from an API, say:
Foo instance = SomeoneElsesAPI.GetFooInstance(id);
I need use Foo, but also add properties to it of my own. The way I can think of doing this is:
class Bar{
private Foo actual;
public Bar(Foo actual)
{
this.actual = actual;
}
public string Prop1 { get {return actual.Prop1; } }
public string Prop2 { get {return actual.Prop2; } }
//...
public string Prop23 { get {return actual.Prop23; } }
public string MyOwnProperty1 { get { return ExternalSource.LoadInfo(actual.Id) } }
}
It feels dirty!
Is there anyone out there that knows how to cleanly expose members of a member as a class's own, or maybe how to extend Foo and have Bar's constructor take an instance of Foo?
Aucun commentaire:
Enregistrer un commentaire