Interface extension + Export/Imports

Aug 7, 2009 at 10:30 PM

Hi All,

    I am trying to understand Exports and Imports a little better. If i have an interace IFeature and in subsequence release i extend that interface to IFeature2 derived from IFeature and add more content to that interface.

interface IFeature
{
   DoSomething();
}

Expport[typeof(IFeature))]
class MyClass : IFeature
{
   DoSomething();
}

interface IFeature2: IFeature
{
   DoSomethingMore();
}

[Export (typeof(IFeature2))]
class MyClass2 : IFeature2
{
   DoSomething();
   DoSomethingMore();
}

In the example above if i ship MyClass and later ship MyClass2 and my host that plugs-in both MyClass and MyClass2 is not update to use the IFeature2 interface ---

In this sceanrio does MyClass2 have to export both IFEature and IFeature2 or is it enough to export IFeature2? If MyClass2 adds the export for IFeature as well and the partcreationpolicy is shared does it create one instance for each of the export types (IFEature & IFeature2)?

 

Thanks very much

Rama

Developer
Aug 7, 2009 at 11:50 PM

Yes you would need to Export MyClass2 with both IFeature and IFeature2 and you are correct that as long as the CreationPolicy is shared then both Exports on MyClass2 will refer to the same object instance.