tags:

views:

85

answers:

1

Hi,

I would like create a very simple Paint application using MAF on WPF.

The Add Ins I would like to create are:

  1. Main Image Processor - Shown the current paint and receive inputs from the user
  2. Tool Box - The user can select some types of drawings tools
  3. Layers - The user can select the layers to display, delete layers and select on which layer to work on

the question is: How I can interact between the different Add-Ins without using the host?

Thanks, Ronny

A: 

The way I do it is for the host to gather each add-in into a collection as they're being discovered, and then pass that collection to each add-in as it initializes it. What you're passing to the add-ins are the other add-ins' interfaces, as that's really all the host knows about them.

The host should initialize each add-in, and then once they're all initialized, signal them to activate, where they then discover the other add-ins and go do their thing. Each add-in should expose a WhoAreYou method so that they can find out who else is installed when they're activated. Deriving your add-ins from a base class will simplify this. Once you've figured it out for one then it's done for all of them.

This approach only uses the host to collect and distribute the add-in interfaces, with the add-ins communicating directly with each other through the contract pipeline instead of routing messages through the host.

ebpower
I'm guessing there is no other way... :)
Ronny
There are less elegant alternatives: You can send messages using MSMQ or by using a database table as a queue (System.Data.Sqlite is great for this).
ebpower