问题描述
我创建了一个抽象的通用基本活动,我从中创建了许多其他活动,我在下面提供了一个简化的代码示例来说明问题:
I created an abstract generic base activity from which I create a number of other activities, I've provided a simplified code sample below to illustrate the problem:
namespace ActivityLibrary
{
public abstract partial class ActivityBase<T> : SequenceActivity
{
public ActivityBase()
{
InitializeComponent();
}
}
}
从此活动继承的每个活动都没有设计师支持,这有点令人讨厌。为了解决这个问题,我最初设计了从SequenceActivity派生的子活动,然后将基类更改为ActivityBase。但是,设计器支持在XOML + CodeBehind工作流中仍然可以正常工作。
但这不是更糟糕的问题 - 一旦我将基本活动类移动到一个单独的项目而不是继承它的活动,工作流设计师试图包含从基本活动中获得的任何活动,这对我来说是个大问题。
以下是样本派生活动的代码:
Every activity that inherits from this activity does not have designer support, which is mildly annoying. To get around this I initially design the child activities derived from SequenceActivity, then change the base class to ActivityBase. However, designer support still works fine in the XOML+CodeBehind workflows.
But this isn't the worse problem - once I move the base activity class to a separate project than the activities which inherit it, the workflow designer breaks trying to include any of the activities that derive from the base activity, which is a big deal to me.
Here's the code for a sample derived activity:
public partial class ActivityBaseInherited : ActivityBase<object>
{
public ActivityBaseInherited()
{
InitializeComponent();
}
}
// Designer File:
namespace ActivityLibrary
{
public partial class ActivityBaseInherited
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.CanModifyActivities = true;
this.getRelocationActivity1 = new ActivityLibrary.GetRelocationActivity();
//
// getRelocationActivity1
//
this.getRelocationActivity1.Name = "getRelocationActivity1";
//
// ActivityBaseInherited
//
this.Activities.Add(this.getRelocationActivity1);
this.Name = "ActivityBaseInherited";
this.CanModifyActivities = false;
}
#endregion
private GetRelocationActivity getRelocationActivity1;
}
}
我是否有办法让至少工作流设计师工作,同时仍然将基类分成不同的项目,并且最好得到派生的活动设计师也可以工作吗?
Is there a way I can make at least the workflow designer work while still separating the base class into a different project and preferrably get the derived activity designers to work as well?
推荐答案
这篇关于活动和设计师支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!