public override void PerformReflection(ReflectionContext context) { Type workflowType = ((WorkflowNode)context.CurrentTreeNode).WorkflowType; DependencyObject workflow = ((WorkflowNode)context.CurrentTreeNode).WorkflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture) as DependencyObject; if (workflow == null) { throw new ApplicationException("Could not create the workflow and cast to DependencyObject"); } RuleDefinitions definitions = workflow.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions; if (definitions != null) { foreach (RuleCondition cond in definitions.Conditions) { RuleNode node = new RuleNode(); node.Rule = cond; node.SelectedImageIndex = node.ImageIndex = context.GetImageIndex(typeof(RuleComponent), RuleNodeImageName); context.CurrentTreeNode.Nodes.Add(node); ReflectChildComponents(context.CreateClone(node)); } } }
private void OnItemClick(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; RuleNode node = (RuleNode)item.Tag; RuleExpressionCondition expressionCondition = (RuleExpressionCondition)node.Rule; WorkflowNode workflowNode = (WorkflowNode)node.Parent; EvaluateRuleDialog dialog = new EvaluateRuleDialog(expressionCondition.Expression, workflowNode.WorkflowType); dialog.ShowDialog(); }
public override void PerformReflection(ReflectionContext context) { Type workflowType = ((WorkflowNode)context.CurrentTreeNode).WorkflowType; DependencyObject workflow = ((WorkflowNode)context.CurrentTreeNode).WorkflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture) as DependencyObject; if (workflow == null) { throw new ApplicationException("Could not create the workflow and cast to DependencyObject"); } RuleDefinitions definitions = workflow.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions; if (definitions != null) { foreach (RuleCondition cond in definitions.Conditions) { RuleNode node = new RuleNode(); node.Rule = cond; node.SelectedImageIndex = node.ImageIndex = context.GetImageIndex(typeof(RuleComponent), RuleNodeImageName); context.CurrentTreeNode.Nodes.Add(node); ReflectChildComponents(context.CreateClone(node)); } } }