在Workflow Rehosted Designer中加载StateMachine元素

时间:2014-02-19 07:27:16

标签: c# workflow

我使用此代码在Designer中创建工具栏,但它不会检索状态机的所有元素,如最终状态。加载状态机的所有元素的正确名称空间是什么?

private static ToolboxControl CreateToolboxControlshahram() {
    const string @namespace = "System.Activities.Statements";
    var toolbox = new ToolboxControl();
    var cat = new ToolboxCategory(@namespace);
    ToolboxItemWrappers(typeof(Flowchart).Assembly, @namespace).ToList().ForEach(cat.Add);
    if (cat.Tools.Count > 0)
        toolbox.Categories.Add(cat);

    return toolbox;
}

private static IEnumerable<ToolboxItemWrapper> ToolboxItemWrappers(Assembly assembly, string @namespace) {
    if (assembly == null) {
        throw new ArgumentNullException("assembly");
    }
    if (string.IsNullOrEmpty(@namespace)) {
        return Enumerable.Empty<ToolboxItemWrapper>();
    }

    var q = from type in assembly.GetTypes()
            where string.Equals(type.Namespace, @namespace)
            && type.IsPublic && !type.IsNested && !type.IsAbstract
            && type.GetConstructor(Type.EmptyTypes) != null
            orderby type.Name
            select new ToolboxItemWrapper(type);
    return q;
}

1 个答案:

答案 0 :(得分:1)

最后我找到了最终状态: 最终状态处于不同的程序集中,我必须编写此代码才能将其添加到我的程序集中 工具箱

ToolboxItemWrapper(typeof ( System.Activities.Core.Presentation.FinalState))
相关问题