在部署到IIS或AppFabric时,如何在Web.config中配置自定义工作流扩展(例如PersistenceParticipant后代)?(对于WF 4)
You can do so in the CacheMetadata of an activity or through a service behavior as follows.
Create an IServiceBehavior to add the extension and a BehaviorExtensionElement to load the IServiceBehavior.
public class MyExtensionElement : BehaviorExtensionElement { public override Type BehaviorType { get { return typeof(MyExtensionBehavior); } } protected override object CreateBehavior() { return new MyExtensionBehavior(); } } public class MyExtensionBehavior : IServiceBehavior { public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase) { var host = (WorkflowServiceHost)serviceHostBase; host.WorkflowExtensions.Add(() => new MyExtension()); } }
Next register it as an behaviorExtensions in the config and use in in your service behavior