Given the following classes:
ClassA
{
public ClassA DoSomethingAndReturnNewObject()
{}
}
ClassB : ClassA
{}
ClassC : ClassA
{}
I finally devised the following solution. For my case it's useful enough, but it assumes that ClassA knows about it's derivatives and is limited to those two options. Not really high-level thinking, but it works. :)
ClassA
{
public ClassA DoSomethingAndReturnNewObject()
{
if (this.GetType() == typeOf(ClassB))
{
return new ClassB(values);
}
else
{
return new ClassC(values):
}
}
}
ClassB : ClassA
{}
ClassC : ClassA
{}