从ModelItem获取WorkflowDesigner

时间:2018-11-13 16:18:44

标签: workflow-foundation-4 workflow-foundation

我正在尝试创建自定义IExpressionEditor。为了重新开始,我需要一个WorkflowDesigner,我所拥有的只是代表我的自定义活动的ModelItem。是否可以从给定的ModelItem访问WorkflowDesigner?

   List<ModelItem> variables = new List<ModelItem>();
   List<ModelItem> nameSpaces = new List<ModelItem>();

   // get the activity from the datacontext
   CustomActivityDesigner cad = this.DataContext as CustomActivityDesigner;
   // try to get the variables
   // look for variables collection cant seem to find them
   ModelProperty mp = cad.ModelItem.Properties["Variables"];

   if(mp != null && mp.PropertyType == typeof(Collection<Variable>))
   {
        mp.Collection.ToList().ForEach(i => variables.Add(i));
   }

   // get name spaces
   ModelProperty mp2 = cad.ModelItem.Properties["NameSpaces"];

   if(mp2 != null && mp2.PropertyType == typeof(Collection<NameSpace>))
   {
        mp2.Collection.ToList().ForEach(i => nameSpaces.Add(i));
   } 

   // finally need the WorkflowDesigner object
   WorkflowDesigner designer = Modelitem.Root....??? as WorkflowDesigner

   // now we have what we need we can create the IExpressionEditor
   CustomExpressionEditior ce = new CustomExpressionEditior(designer, variables, nameSpaces)

1 个答案:

答案 0 :(得分:-1)

Using a Custom Expression Editor为例,看来您应该能够创建自定义表达式服务(它将创建 Expression Editor 实例),并且将其注册到 WorkflowDesigner 上的Services集合中。

WorkflowDesigner Services集合中注册后,您将能够:

希望有帮助!