I would like create a very simple Paint application using MAF on WPF.
The Add Ins I would like to create are:
- Main Image Proc开发者_如何学运维essor - Shown the current paint and receive inputs from the user
- Tool Box - The user can select some types of drawings tools
- 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
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.
精彩评论