WF4.0 Beta1 参数 Arguments
目录
3.1 [In参数]是[System.Activities.InArgument<T>]类型的属性, 1
3.2 设计时,可以在属性框中,对[In参数]的赋值,[In参数]的赋值要使用"表达式"方式 2
3.4 [In参数]不能在实例的[OnCompleted]事件中用[WorkflowCompletedEventArgs.Outputs]得到 3
4.1 [Out参数]是[System.Activities.OutArgument<T>]类型的属性, 3
4.2 [Out参数]可在实例的[OnCompleted]事件中用[WorkflowCompletedEventArgs.Outputs]得到 4
4.3 运行时,可以启动参数的方式对[Out 参数]赋值 4
4.6 [out参数]可以在流程内部被其它[表达式]引用 5
5.1 1.[In/Out参数]是[System.Activities.InOutArgument<T>]类型的属性 5
5.3 设计时,不能在属性框中,对[In/Out参数]的赋值 6
5.5 [In/Out参数]可以在流程内部被其它[表达式]引用 6
Arguments是WF的输出和输入接口.参数属性Direction,有In,Out,In/Out,Propery选项
[In,Out,In/Out]参数使用说明
启动传参 | OnCompleted 事件访问 | 属性栏赋值 | 表达式访问 | Assign 赋值 | |
In | V | X | V | V | X |
Out | V | V | X | V | V |
In/Out | V | V | X | V | V |
定义
Arguments
In参数
[In参数]是[System.Activities.InArgument<T>]类型的属性,
代码定义方式
public class myElement : CodeActivity {
protected override void Execute(CodeActivityContext context) { string v = s.Get(context); System.Console.WriteLine(v);
}
public System.Activities.InArgument<string> s { set; get; }
} |
xaml定义方式
<p:Activity mc:Ignorable="" x:Class="WorkflowConsoleApplication3.myActivity" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/design" xmlns:__myActivity="clr-namespace:WorkflowConsoleApplication3;" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <x:Members> <x:Property Name="s" Type="p:InArgument(x:String)" /> </x:Members> <p:WriteLine>[s]</p:WriteLine> </p:Activity> |
设计时,可以在属性框中,对[In参数]的赋值,[In参数]的赋值要使用"表达式"方式
流程 | |
宿主 | WorkflowInstance myInstance = new WorkflowInstance(new Sequence1()); myInstance.Run(); |
结果 |
运行时,可以启动参数的方式对[In参数]赋值
宿主 | System.Collections.Generic.Dictionary<string, object> d = new Dictionary<string, object>(); d.Add("s", "wxwinter");
WorkflowInstance myInstance = new WorkflowInstance(new myElement(),d); myInstance.Run(); |
结果 |
[In参数]不能在实例的[OnCompleted]事件中用[WorkflowCompletedEventArgs.Outputs]得到
[In参数]不能用[Assign]赋值
[In参数]可以在流程内部被其它[表达式]引用
Out 参数
[Out参数]是[System.Activities.OutArgument<T>]类型的属性,
代码定义方式如下:
public class myElement : CodeActivity {
protected override void Execute(CodeActivityContext context) { string v = s.Get(context); s.Set(context, "wxd:" + v);
}
public System.Activities.OutArgument<string> s { set; get; }
} } |
xaml定义方式
<p:Activity mc:Ignorable="" x:Class="WorkflowConsoleApplication3.myActivity" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/design" xmlns:__myActivity="clr-namespace:WorkflowConsoleApplication3;" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <x:Members> <x:Property Name="s" Type="p:OutArgument(x:String)" /> </x:Members> <p:WriteLine>[s]</p:WriteLine> </p:Activity> |
[Out参数]可在实例的[OnCompleted]事件中用[WorkflowCompletedEventArgs.Outputs]得到
class Program { static void Main(string[] args) {
WorkflowInstance myInstance = new WorkflowInstance(new myElement()); myInstance.OnCompleted += completed; myInstance.Run(); System.Console.Read();
} static void completed(WorkflowCompletedEventArgs e) { System.Console.WriteLine(e.Outputs["s"].ToString()); }
} |
运行时,可以启动参数的方式对[Out 参数]赋值
宿主 | class Program { static void Main(string[] args) { System.Collections.Generic.Dictionary<string, object> d = new Dictionary<string, object>();
d.Add("s", "wxwinter");
WorkflowInstance myInstance = new WorkflowInstance(new myElement(),d); myInstance.OnCompleted += completed; myInstance.Run();
System.Console.Read();
} static void completed(WorkflowCompletedEventArgs e) { System.Console.WriteLine(e.Outputs["s"].ToString()); }
} |
结果 |
设计时,不能在属性框中,对[In参数]的赋值
[out参数]可用[Assign]赋值
[out参数]可以在流程内部被其它[表达式]引用
In/Out参数
1.[In/Out参数]是[System.Activities.InOutArgument<T>]类型的属性
代码定义方式
public class myElement : CodeActivity { protected override void Execute(CodeActivityContext context) { string v = s.Get(context);
s.Set(context, "wxd:" + v); }
public System.Activities.InOutArgument<string> s { set; get; } } |
xoml方式
<p:Activity mc:Ignorable="" x:Class="WorkflowConsoleApplication3.myActivity" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities/design" xmlns:__myActivity="clr-namespace:WorkflowConsoleApplication3;" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <x:Members> <x:Property Name="s" Type="p:InOutArgument(x:String)" /> </x:Members> <p:WriteLine>[s]</p:WriteLine> </p:Activity> |
2.运行时,可以启动参数的方式对[IN/Out 参数]赋值,可在实例的[OnCompleted]事件中用[WorkflowCompletedEventArgs.Outputs]得到[IN/Out 参数]值
class Program { static void Main(string[] args) { System.Collections.Generic.Dictionary<string, object> d = new System.Collections.Generic.Dictionary<string, object>();
d.Add("s", "wxwinter");
WorkflowInstance myInstance = new WorkflowInstance(new myElement(),d); myInstance.OnCompleted += completed; myInstance.Run();
System.Console.Read();
} static void completed(WorkflowCompletedEventArgs e) {
System.Console.WriteLine(e.Outputs["s"].ToString()); }
} |
设计时,不能在属性框中,对[In/Out参数]的赋值
[In/Out参数]可用[Assign]赋值