I have an API that I have to provide a higher level, more friendly, more streamlined framework by wrapping.
This API is already wrapped identical from its unmanaged version. But it has all sorts of unintuitive member names, workflows, etc.
I am using composition to store a reference to the underlying type that way I can have members the way I want. Bas开发者_StackOverflowically converting and combining certain functions to properties, having higher level functionality using some other lower level logic, etc.
public class Effect
{
public IEffect {get; private set;}
...
}
But one thing that I start thinking about is since the original C++ API is heavily based on inheritance and virtual methods, how should I go about "exposing"/wrapping/chaining these?
Should I just provide additional methods that calls the internalType.VirtualMethod()
, etc? But this seems like it wouldn't work, right?
But on the other hand, if I use Inheritance myself like:
public class Effect : IEffect
then I will have all these members and weird, obsolote functions coming with it. I can still provide my higher level functionality but I don't want to show these members, because of many reasons, one of the simpliest one being they are not .NET like.
What do you suggest to accomplish this?
Write a wrapper class. In the long term, you'll be glad you did.
精彩评论