DotLee

开源项目dropthings的工作流接口IWorkflowHelper

这是开源项目dropthings的工作流接口IWorkflowHelper

 系统版本 Dropthings-2.1

IWorkflowHelper代码

namespace Dropthings.Business.Workflows
{
    using System;
    using System.Workflow.Runtime;

    public interface IWorkflowHelper
    {
        #region Methods

        void ExecuteWorkflow(WorkflowRuntime runtime, Type workflowType, System.Collections.Generic.Dictionary<string, object> properties);

        TResponse ExecuteWorkflow<TWorkflow, TRequest, TResponse>(WorkflowRuntime runtime, TRequest request)
            where TResponse : new();

        #endregion Methods
    }
}

 

其中,定义了执行工作流的2个方法。主要是负责初始化工作流的执行环境及准备执行工作流。
在第二个方法中,用到了c#2005(C#2.0)中添加的新功能泛型。
这个功能,在c#2008(c#3.0)中没有变化。
TWorkflow, TRequest, TResponse是泛型类型描述性的名称,用字母T作为前缀,可以用任意类来代替他们。
where TResponse : new() 是一个构造器约束,TResponse必须要有一个默认构造器。
并且,在clr2.0中(.net2 /3/3.5的clr都是clr2.0),只能为默认构造器定义约束,而不能为其他构造器。

在c#的说明文档中,有如下的提示:
  where子句的一个重要限制,不能定义必须有泛型类型执行的运算符,运算符不能在接口中定义。
  在where子句中,只能定义基类、接口和默认构造函数。

posted on 2009-05-17 22:58  DotLee  阅读(466)  评论(1编辑  收藏  举报