0

I am creating an Extensible application using MEF to allow my customer to develop their own modules and extensions, i have some special exports like integrated modules, and i want to prevent other developers from importing or rewriting that modules, please guide me how to do that.

for example: i have the IShellService

public interface IShellService
{
    // providing the shell functions and properties
}

and an interface for the DashboardModule

public Interface IDashboardModule {}

Consuming IShellService in a Module looks as follows:

Export(typeof(IModule))
public MyModule
{ 
    [ImportConstructor]
    public MyModule(IShellService shellservice)
    {
       // ...
    }
}

how to ensure that the MyModule will use in the constructor the Shell Service that i provided in the Shell, not an other one that some Modules created, because may some one will export a module with this type IShellService in this case the MEF will confuse between two Exported values of and i want it be one export and one import, no one can export this type.

The same problem with the Dashboard Module, i want only my Dashboard Module Implementation (Exportation).

Liam
  • 27,717
  • 28
  • 128
  • 190
Henka Programmer
  • 433
  • 6
  • 18
  • 1
    use a [source control](http://en.wikipedia.org/wiki/Revision_control). [Obfuscate your code](http://en.wikipedia.org/wiki/Obfuscation_%28software%29) – lloyd May 17 '15 at 07:14
  • you have to give us a basic layout of your program , what parts you want developers to have access to and what parts they shouldn't have access to . – eran otzap May 17 '15 at 11:29

1 Answers1

1

Not a mef expert, but you may want to have a look at ExportsMetaData attribute : "Exports can provide additional information about themselves known as metadata. Metadata can be used to convey properties of the exported object to the importing part. The importing part can use this data to decide which exports to use, or to gather information about an export without having to construct it. For this reason, an import must be lazy to use metadata.". More info at: https://msdn.microsoft.com/en-us/library/vstudio/ee155691%28v=vs.100%29.aspx#metadata_and_metadata_views

Ahmad
  • 1,462
  • 15
  • 23