This question is in compliance with COM interop for me.
Assume that I implement the following 2 interfaces and classes:
Public Interface Esquitum {public string SKU {get; Set; }} Public Interface ICartItem: ISkuItem {Public Int Amount {Received; Set; } Public Boole isdiscountable {get; Set; }} Public class CartItem: ICartItem {// implemented properties ...} Or, in VB.NET:
public interface ISkuItem property SKU ( ) As the string end interface folk interface ICartItem inherited ISkuItem property volume () Integer property IsDiscountable (as) Boolean end interface Folk Classes CartItem Implements ICartItem 'Apply Properties' as the End Class The interface is important in VB6 IDE (copy) properties of IntelliSense and COM Interop to highlight methods. However, because ICartItem ISkuItem , SKU is not explicitly defined in ICartItem and received in this way Does not appear in IntelliSense in VB6 and even throws a compiler error trying to write objCartItem.SKU .
I have tried using shadow and overloads squ on ISkuItem property, but then The compiler wants to explicitly apply me to SKU for both > ISkuItem and ICartItem within CartItem category. I do not think what I want.
SKU There is no way to explicitly declare the property in (in VB.Net or C #) ICartItem without declaring twice in class SKU croreitim
as you Matthew shows what to do and ( It seems that this interface succession model is not working for you. Do you make sure that having Instead of the heirs of a headache sufferer on this, I would probably want to do just offer the code shadow ) SKU for the member ICartItem . But as I'm sure you feel, it renders your interface legacy in vain. your own ICartItem to ISkuItem are you actually buying anything? SKU and < From Code> ISkuItem . Then ICollection & lt; T & gt; and Icoding ); But in any case it will have a SKU property.
Do not like this design, I will make in general , what I have in mind;); But when it comes to COM interop, sometimes you have to sacrifice because you do not always want to push your head against the wall.
I'm not sure that you will find a satisfactory answer on this one VB6 just flat-out does not understand everything that .NET does, so you have .NET features for COM counterparts. Can not understand a perfect 1: 1 mapping.
Comments
Post a Comment