积极答复者
自定义Activity属性能在Activity内部使用吗?

问题
-
问题一:自定义Activity1.xaml,参数栏可以自定义的参数方向为三种,“输入”、“输入输出”、“属性”,输入和输入输出都可以直接在Activity1中直接使用,但是属性不能直接使用,想问问怎么使用属性?
问题二:输入、输入输出参数的类型为非“字符串”及“数值”类型时,系统会报错,代码如下:
public bool Save(IRootActivity rootActivity) { try { XElement flowXml = TranslateToXml(rootActivity, false, null, null, null); Activity userDefinflow = rootActivity.TranslateToXaml(); string define = XamlServices.Save(userDefinflow); #region 测试流程 var idleEvent = new AutoResetEvent(false); var workflowApplication = new WorkflowApplication(userDefinflow) { Idle = delegate { idleEvent.Set(); }, Completed = delegate(WorkflowApplicationCompletedEventArgs e) { var outputs = e.Outputs; } }; workflowApplication.Run(); idleEvent.WaitOne(); #endregion SaveFile(flowXml, define); return true; } catch (ArgumentNullException e) { MessageBox.Show(e.Message); return false; } catch (Exception e) { MessageBox.Show(e.Message); return false; } }
其中在执行代码:workflowApplication.Run();时报如下错误,不知道是为什么呢?
处理工作流树时遇到以下错误:
'Literal<Application>': 文本仅支持值类型和不可变类型 System.String。类型 WorkflowPlatform.Model.Application 不能用作文本。
'Literal<Dictionary<String,MemberItem>>': 文本仅支持值类型和不可变类型 System.String。类型 System.Collections.Generic.Dictionary`2[System.String,WorkflowPlatform.Model.MemberItem] 不能用作文本。
'Literal<List<INotifyService>>': 文本仅支持值类型和不可变类型 System.String。类型 System.Collections.Generic.List`1[WorkflowPlatform.Core.Interface.INotifyService] 不能用作文本。
'Literal<Dictionary<String,MemberItem>>': 文本仅支持值类型和不可变类型 System.String。类型 System.Collections.Generic.Dictionary`2[System.String,WorkflowPlatform.Model.MemberItem] 不能用作文本。
'Literal<List<INotifyService>>': 文本仅支持值类型和不可变类型 System.String。类型 System.Collections.Generic.List`1[WorkflowPlatform.Core.Interface.INotifyService] 不能用作文本。
答案
-
你好,
属性通常使用公开的get和set方法,在workflow中的属性有很多的限制,它的值必须在编译时就确定,不能在活动的生命周期中更改,表现就像一个常量。比如方法名就是活动公开的一个属性。详细的内容,请参见文档:
http://msdn.microsoft.com/en-us/library/gg281650.aspx
第二问题中提供的代码不完整,无法用来重现问题,你是否可以更多详细的信息。谢谢。
Leo Tang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已标记为答案 cakeMSDN 2011年11月8日 6:49
全部回复
-
你好,
属性通常使用公开的get和set方法,在workflow中的属性有很多的限制,它的值必须在编译时就确定,不能在活动的生命周期中更改,表现就像一个常量。比如方法名就是活动公开的一个属性。详细的内容,请参见文档:
http://msdn.microsoft.com/en-us/library/gg281650.aspx
第二问题中提供的代码不完整,无法用来重现问题,你是否可以更多详细的信息。谢谢。
Leo Tang [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.- 已标记为答案 cakeMSDN 2011年11月8日 6:49