当前位置:  开发笔记 > 运维 > 正文

在Web.config中添加工作流扩展

如何解决《在Web.config中添加工作流扩展》经验,为你挑选了1个好方法。

在部署到IIS或AppFabric时,如何在Web.config中配置自定义工作流扩展(例如PersistenceParticipant后代)?(对于WF 4)



1> Maurice..:

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


    
        
            
        
    
    
        
            
                
            
        
    

推荐阅读
kikokikolove
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有