C# 使用来自其他互操作的自定义活动 短版
我想在另一个活动中使用一个活动,我找到的唯一解决方案是使用C# 使用来自其他互操作的自定义活动 短版,c#,.net,xaml,workflow-foundation-4,workflow-foundation,C#,.net,Xaml,Workflow Foundation 4,Workflow Foundation,我想在另一个活动中使用一个活动,我找到的唯一解决方案是使用Interop activity。但现在我对工作流基金会4.5互操作遇到了一些问题 长版本 我的项目是C#NET 4.5 我的第一个活动是在两个双打之间做一个简单的加法。我使用xaml设计器工具完成了这一步。 我的第二个活动只是使用互操作活动调用第一个活动 这里是我的视图模型:MyMain.cs: public class MyMain : INotifyPropertyChanged { private doub
Interop activity
。但现在我对工作流基金会4.5互操作遇到了一些问题
长版本
我的项目是C#NET 4.5我的第一个活动是在两个双打之间做一个简单的加法。我使用xaml设计器工具完成了这一步。
我的第二个活动只是使用互操作活动调用第一个活动 这里是我的视图模型:MyMain.cs:
public class MyMain : INotifyPropertyChanged
{
private double a, b, c, d, e, f, g;
public double A
{
get { return a; }
set
{
if (a == value) return;
a = value;
OnPropertyChanged("A");
}
}
public double B
{
get { return b; }
set
{
if (b == value) return;
b = value;
OnPropertyChanged("B");
}
}
public double G
{
get { return g; }
set
{
if (g == value) return;
g = value;
OnPropertyChanged("G");
}
}
public void Do()
{
Activity act = testing();
Dictionary<string, object> ins = new Dictionary<string, object>();
ins.Add("A", A);
ins.Add("B", B);
var output = WorkflowInvoker.Invoke(act, ins);
MessageBox.Show(output["G"].ToString());
}
public DynamicActivity testing()
{
A = 5.3;
B = 2.1;
// Define the Input and Output arguments that the DynamicActivity binds to
var aa = new InArgument<double>(A);
var bb = new InArgument<double>(B);
var gg = new OutArgument<double>();
return new DynamicActivity()
{
Properties =
{
new DynamicActivityProperty() {Name = "AA", Type = typeof (InArgument<double>), Value = aa},
new DynamicActivityProperty() {Name = "BB", Type = typeof (InArgument<double>), Value = bb},
new DynamicActivityProperty() {Name = "GG", Type = typeof (OutArgument<double>), Value = gg}
},
Implementation = () =>
new Sequence
{
Activities =
{
new Interop()
{
ActivityType = typeof(Adds),
ActivityProperties =
{
{"A", new InArgument<double>(env => aa.Get(env))},
{"B", new InArgument<double>(env => bb.Get(env))},
{"C", new OutArgument<double>(env => gg.Get(env))}
}
}
}
}
};
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propName)
{
if (PropertyChanged != null)
{
MessageBox.Show(propName);
PropertyChanged(this, new PropertyChangedEventArgs(propName));
}
}
#endregion
}
我的执行错误(我翻译错误,因为它通常是法语):
这里是法国,如果可以的话:
'DynamicActivity': L'implémentation privée de l'activité '1: DynamicActivity' présente l'erreur de validation suivante : Valeur incorrecte spécifiée pour la propriété 'ActivityType' de l'activité Interop 'Interop'.
La valeur de cette propriétédoitêtre un System.键入qui hérite de System.工作流.组件模型.活动。我解决了我的问题。
通常,如果您的活动工作正常,您可以在工具箱中的xaml工作流中的指定div中找到它们
将为每个项目/名称空间添加一个指定div,您可以从这些名称空间中查找并拖放活动
System.Activities.Statements.Interop is obsolete: The WF3 Types are deprecated. Instead, please use the new WF4 Types from System.Activities.*
DynamicActivity': The private implementation of the activity
'1: DynamicActivity' gives the follow validation error : Invalid value specify for the property 'ActivityType' of the Interop Activity 'Interop'.
The value of this property have to be System.Type which herite ofSystem.Workflow.ComponentModel.Activity.
'DynamicActivity': L'implémentation privée de l'activité '1: DynamicActivity' présente l'erreur de validation suivante : Valeur incorrecte spécifiée pour la propriété 'ActivityType' de l'activité Interop 'Interop'.