⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workflow17.xoml.cs

📁 WWF中的基本活动的简单示例,例如IfElseActivity、WhileActivity活动
💻 CS
字号:
//《WF编程》系列之17 - 工作流与外部事件:工作流参数 
//3.2.2 工作流参数
//Runtime的CreateWorkflow方法有一个重载允许我们向新的工作流实例传递参数,参数的类型是Dictionary(名值对的集合).

//当工作流Runtime创建了新的工作流实例时,它会尝试寻找每个参数名称的伴随属性(Companion Property).伴随属性是工作流对象中公开并可写的属性,它们有着和工作流参数项相同的名字.举例来说,工作流会接受上面代码中的FirstName和LastName参数是因为在其内部有着同样名字的属性:

//如果我们尝试传递一个FullName参数,Runtime会抛出异常,因为FullName属性是只读的.Runtime无法为其找到相应的公开并可写的伴随属性,
//Runtime会抛出System.ArgumentException异常.对于参数来说,必须有公开并可写的属性与之对应;
//而对属性来说,并不是每一个公开并可写的属性都必须对应一个参数,输入参数是可选的.
//工作流内的活动不需要关心如何取得参数值.Runtime会在工作流执行前将所有的参数指派给相应的属性.
//在代码中, CodeActivity的ExecuteCode事件将接收到的FirstName和LastName参数合并到FullName属性中.
//不仅仅可以向工作流输入数据,我们还可以将FullName属性作为工作流的输出参数.
//当工作流完成时,Runtime触发WorkflowCompleted事件, 该事件的WorkflowCompletedEventArgs参数包含一个OutputParameters属性(输出参数的Dictionary集合),
//Runtime将复制每个公开可读的工作流属性到OutputParameters集合中.



using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace WorkflowConsoleApplication1
{
	public partial class Workflow17 : SequentialWorkflowActivity
	{

    
        public string FirstName
        {

            set { _firstName = value; }

        }

        private string _firstName;

        //只写

        public string LastName
        {

            set { _lastName = value; }

        }

        private string _lastName;

        //只读

        public string FullName
        {

            get { return this._firstName + "iii"+this._lastName ; }

        }

        
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -