Tru*_*ill 2 configuration web-config workflow-foundation workflow-foundation-4
在部署到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<MyExtension>(() => new MyExtension());
}
}
Run Code Online (Sandbox Code Playgroud)
Next register it as an behaviorExtensions in the config and use in in your service behavior
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="myExtension"
type="MyWorkflowService.MyExtensionElement, MyWorkflowService"/>
</behaviorExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior>
<myExtension/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2298 次 |
| 最近记录: |