开发者

Adding workflow extension in Web.config

How do you configure a custom workflow extension (such as a PersistenceParticipant descendant) in Web.开发者_高级运维config when deploying to IIS or AppFabric? (For 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());
    }
}

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜