我想创建一个使用MAF WPF的一个非常简单的画图程序。
I would like create a very simple Paint application using MAF on WPF.
该加载项我想创建是:
在主图像处理器 - 显示的当前油漆和接收来自用户的输入 工具箱 - 用户可以选择某些类型的绘图工具 图层 - 用户可以选择要显示的图层,删除图层,然后选择在哪一层上班问题是:我怎么能在不同的加载项之间不使用主机交互
the question is: How I can interact between the different Add-Ins without using the host?
谢谢, 罗尼
我的方式做到这一点是主机收集每个加载到一个集合,因为它们可以被发现,然后将该集合传递给每增加 - 在它初始化。什么你传递给加载项是其他加载项界面,因为这是真正的所有主机知道它们。
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.
应该初始化主机每个加载项,然后一旦他们全部初始化,它们的信号激活,在那里他们然后发现的其他加载项,然后去做自己的事情。每一个加载项应公开一个WhoAreYou方法,使他们能够找到谁,当他们正在启动其他的安装了。从基类派生您的加载项将简化。一旦你理解了它的一个,那么它的完成了所有的人。
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.