如果活动是在单独的程序集中定义的,如何将扩展添加到 WF4 服务工作流中?
我有一个定义一些服务接口的程序集(例如 IAddressBookService)。我已在常见 WF 活动的程序集中引用了该程序集。当我的一项常见活动想要使用该服务时,我想从上下文扩展中获取该服务的引用,例如,
IAddressBookService myService = context.GetExtension<IAddressBookService>()
我想在 IIS 托管的工作流服务中使用这些常见活动之一。但是我不知道应该在哪里将 IAddressBookService 的具体实现添加到工作流上下文中。我的通用活动程序集没有引用我的具体实现,因为我只希望该库引用接口,所以我不能使用“CacheMetadata”覆盖,并且我没有看到任何肯定会被调用的方法我在 IIS 中的工作流服务活动在启动之前。另外,据我所知,在 IIS 上托管服务时 WorkFlowExtenstionManager 不可用。是否有任何通用模式可以解决这个问题,或者我应该创建某种服务定位器来为我做到这一点?
谢谢。
麦克风
I have an assembly that defines some service interfaces (e.g. IAddressBookService). I have referenced that assembly in an assembly of common WF activities. When one of my common activities wants to use that service I want to get a reference for the service from the context extenstions e.g.
IAddressBookService myService = context.GetExtension<IAddressBookService>()
I want to use one of these common activities in a WorkFlow Service hosted by IIS. However I can't figure out where I should add the concrete implmentation of IAddressBookService into the workflow context. My concrete implmentations are not referenced by my assembly of common activites as I only want that library to reference the interfaces, so I can't use the "CacheMetadata" override, and I don't see any methods that are sure to be called on my workflow service activity in IIS before it starts up. Also, as far I as can tell the WorkFlowExtenstionManager is not available when hosting the service on IIS. Is there any common pattern for solving this or should I just create some sort of service locator to do this for me?
Thanks.
Mike
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好的方法是定义一个BehaviorExtensionElement并将其添加到web.config中。请参阅我对此的回答此 举个例子的问题。
The best way is by defining a BehaviorExtensionElement and adding that to the web.config. See my answer to this question for an example.