Пример #1
0
        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));
                }
            }
        }
Пример #2
0
        public override void PerformReflection(ReflectionContext context)
        {
            Type[] workflowTypes = context.WorkflowAssembly.GetWorkflowTypes();

            if (workflowTypes == null)
            {
                return;
            }

            foreach (Type workflowType in workflowTypes)
            {
                WorkflowNode workflowNode = new WorkflowNode();
                workflowNode.Name               = workflowType.Name;
                workflowNode.Text               = workflowType.FullName;
                workflowNode.WorkflowType       = workflowType;
                workflowNode.SelectedImageIndex = workflowNode.ImageIndex = context.GetImageIndex(typeof(WorkflowComponent), WorkflowNodeImageName);

                context.CurrentTreeNode.Nodes.Add(workflowNode);
                ReflectChildComponents(context.CreateClone(workflowNode));
            }

            if (context.WorkflowAssembly.GetWorkflowTypes().Length == 0)
            {
                TreeNode node = new TreeNode();
                node.Text = "<No Workflows Found>";

                context.CurrentTreeNode.Nodes.Add(node);
            }
        }
Пример #3
0
        public override void PerformReflection(ReflectionContext context)
        {
            AssemblyNode assemblyNode = new AssemblyNode();
            assemblyNode.Text = Path.GetFileName(context.WorkflowAssembly.Assembly.Location);
            assemblyNode.Assembly = context.WorkflowAssembly;
            assemblyNode.SelectedImageIndex = assemblyNode.ImageIndex = context.GetImageIndex(typeof(AssemblyComponent), AssemblyNodeImageName);

            context.TreeView.Nodes.Add(assemblyNode);

            ReflectChildComponents(context.CreateClone(assemblyNode));
        }
Пример #4
0
        public override void PerformReflection(ReflectionContext context)
        {
            AssemblyNode assemblyNode = new AssemblyNode();

            assemblyNode.Text               = Path.GetFileName(context.WorkflowAssembly.Assembly.Location);
            assemblyNode.Assembly           = context.WorkflowAssembly;
            assemblyNode.SelectedImageIndex = assemblyNode.ImageIndex = context.GetImageIndex(typeof(AssemblyComponent), AssemblyNodeImageName);

            context.TreeView.Nodes.Add(assemblyNode);

            ReflectChildComponents(context.CreateClone(assemblyNode));
        }
Пример #5
0
        public override void PerformReflection(ReflectionContext context)
        {
            WorkflowNode workflowNode = context.CurrentTreeNode as WorkflowNode;

            if (workflowNode == null)
            {
                throw new ApplicationException("Expected the parent node to be a workflow node.");
            }

            object workflowInstance = null;

            try
            {
                workflowInstance = workflowNode.WorkflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Could not create workflow type: " + exc.ToString());
                return;
            }

            TreeNode activitiesNode = new TreeNode();

            activitiesNode.Text       = "Activities";
            activitiesNode.ImageIndex = activitiesNode.SelectedImageIndex = context.GetImageIndex(typeof(WorkflowActivitiesComponent), ActivitiesNodeImageName);

            workflowNode.Nodes.Add(activitiesNode);

            if (!(workflowInstance is CompositeActivity))
            {
                TreeNode none = new TreeNode();
                none.Text = "<Workflow is not a CompositeActivity>";
                activitiesNode.Nodes.Add(none);
            }
            else
            {
                Queue <KeyValuePair <CompositeActivity, TreeNode> > toProcess = new Queue <KeyValuePair <CompositeActivity, TreeNode> >();
                toProcess.Enqueue(new KeyValuePair <CompositeActivity, TreeNode>((CompositeActivity)workflowInstance, activitiesNode));

                while (toProcess.Count > 0)
                {
                    KeyValuePair <CompositeActivity, TreeNode> pair = toProcess.Dequeue();
                    CompositeActivity compositeActivity             = pair.Key;
                    TreeNode          parent = pair.Value;

                    foreach (Activity activity in compositeActivity.Activities)
                    {
                        ActivityNode activityNode = new ActivityNode();
                        activityNode.Activity   = activity;
                        activityNode.ImageIndex = activityNode.SelectedImageIndex = context.GetImageIndex(typeof(WorkflowActivitiesComponent), ActivityNodeImageName);
                        parent.Nodes.Add(activityNode);

                        ReflectChildComponents(context.CreateClone(activityNode));

                        if (activity is CompositeActivity)
                        {
                            toProcess.Enqueue(new KeyValuePair <CompositeActivity, TreeNode>((CompositeActivity)activity, activityNode));
                        }
                    }
                }
            }
        }
Пример #6
0
        public override void PerformReflection(ReflectionContext context)
        {
            Type workflowType = ((WorkflowNode)context.CurrentTreeNode).WorkflowType;

            object workflowInstance = null;

            try
            {
                workflowInstance = workflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Workflow type could not be created: " + exc.ToString());
                return;
            }

            Activity root = (Activity)workflowInstance;

            Queue <Activity> toProcess       = new Queue <Activity>();
            List <Type>      foundInterfaces = new List <Type>();

            toProcess.Enqueue(root);

            while (toProcess.Count > 0)
            {
                Activity activity = toProcess.Dequeue();

                if (activity is CompositeActivity)
                {
                    CompositeActivity compositeActivity = (CompositeActivity)activity;

                    foreach (Activity child in compositeActivity.Activities)
                    {
                        toProcess.Enqueue(child);
                    }
                }
                else if (activity is HandleExternalEventActivity)
                {
                    HandleExternalEventActivity eventSink = (HandleExternalEventActivity)activity;

                    if (!foundInterfaces.Contains(eventSink.InterfaceType))
                    {
                        foundInterfaces.Add(eventSink.InterfaceType);
                    }
                }
                else if (activity is CallExternalMethodActivity)
                {
                    CallExternalMethodActivity invoke = (CallExternalMethodActivity)activity;

                    if (!foundInterfaces.Contains(invoke.InterfaceType))
                    {
                        foundInterfaces.Add(invoke.InterfaceType);
                    }
                }
            }

            foreach (Type service in foundInterfaces)
            {
                ServiceInterfaceNode node = new ServiceInterfaceNode();
                node.ServiceInterfaceType = service;
                node.Text = "Required Service: " + service.FullName;
                node.SelectedImageIndex = node.ImageIndex = context.GetImageIndex(typeof(RequiredServiceInterfacesComponent), ServiceInterfaceNodeImageName);

                context.CurrentTreeNode.Nodes.Add(node);
                ReflectChildComponents(context.CreateClone(node));
            }
        }
Пример #7
0
        public override void PerformReflection(ReflectionContext context)
        {
            WorkflowNode workflowNode = context.CurrentTreeNode as WorkflowNode;

            if (workflowNode == null)
            {
                throw new ApplicationException("Expected the parent node to be a workflow node.");
            }

            object workflowInstance = null;

            try
            {
                workflowInstance = workflowNode.WorkflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Could not create workflow type: " + exc.ToString());
                return;
            }

            TreeNode activitiesNode = new TreeNode();
            activitiesNode.Text = "Activities";
            activitiesNode.ImageIndex = activitiesNode.SelectedImageIndex = context.GetImageIndex(typeof(WorkflowActivitiesComponent), ActivitiesNodeImageName);

            workflowNode.Nodes.Add(activitiesNode);

            if (!(workflowInstance is CompositeActivity))
            {
                TreeNode none = new TreeNode();
                none.Text = "<Workflow is not a CompositeActivity>";
                activitiesNode.Nodes.Add(none);
            }
            else
            {
                Queue<KeyValuePair<CompositeActivity, TreeNode>> toProcess = new Queue<KeyValuePair<CompositeActivity, TreeNode>>();
                toProcess.Enqueue(new KeyValuePair<CompositeActivity, TreeNode>((CompositeActivity)workflowInstance, activitiesNode));

                while (toProcess.Count > 0)
                {
                    KeyValuePair<CompositeActivity, TreeNode> pair = toProcess.Dequeue();
                    CompositeActivity compositeActivity = pair.Key;
                    TreeNode parent = pair.Value;
                    
                    foreach (Activity activity in compositeActivity.Activities)
                    {
                        ActivityNode activityNode = new ActivityNode ();
                        activityNode.Activity = activity;
                        activityNode.ImageIndex = activityNode.SelectedImageIndex = context.GetImageIndex(typeof(WorkflowActivitiesComponent), ActivityNodeImageName);
                        parent.Nodes.Add(activityNode);

                        ReflectChildComponents(context.CreateClone(activityNode));

                        if (activity is CompositeActivity)
                        {
                            toProcess.Enqueue(new KeyValuePair<CompositeActivity, TreeNode>((CompositeActivity)activity, activityNode));
                        }
                    }
                }
            }
        }
Пример #8
0
        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));
                }
            }
        }
Пример #9
0
        public override void PerformReflection(ReflectionContext context)
        {
            Type workflowType = ((WorkflowNode)context.CurrentTreeNode).WorkflowType;

            object workflowInstance = null;

            try
            {
                workflowInstance = workflowType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, null, CultureInfo.InvariantCulture);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Workflow type could not be created: " + exc.ToString());
                return;
            }

            Activity root = (Activity)workflowInstance;

            Queue<Activity> toProcess = new Queue<Activity>();
            List<Type> foundInterfaces = new List<Type>();
            toProcess.Enqueue(root);

            while (toProcess.Count > 0)
            {
                Activity activity = toProcess.Dequeue();

                if (activity is CompositeActivity)
                {
                    CompositeActivity compositeActivity = (CompositeActivity)activity;

                    foreach (Activity child in compositeActivity.Activities)
                    {
                        toProcess.Enqueue(child);
                    }
                }
                else if (activity is HandleExternalEventActivity)
                {
                    HandleExternalEventActivity eventSink = (HandleExternalEventActivity)activity;

                    if (!foundInterfaces.Contains(eventSink.InterfaceType))
                    {
                        foundInterfaces.Add(eventSink.InterfaceType);
                    }
                }
                else if (activity is CallExternalMethodActivity)
                {
                    CallExternalMethodActivity invoke = (CallExternalMethodActivity)activity;

                    if (!foundInterfaces.Contains(invoke.InterfaceType))
                    {
                        foundInterfaces.Add(invoke.InterfaceType);
                    }
                }
            }

            foreach (Type service in foundInterfaces)
            {
                ServiceInterfaceNode node = new ServiceInterfaceNode();
                node.ServiceInterfaceType = service;
                node.Text = "Required Service: " + service.FullName;
                node.SelectedImageIndex = node.ImageIndex = context.GetImageIndex(typeof(RequiredServiceInterfacesComponent), ServiceInterfaceNodeImageName);

                context.CurrentTreeNode.Nodes.Add(node);
                ReflectChildComponents(context.CreateClone(node));
            }
        }
Пример #10
0
        public override void PerformReflection(ReflectionContext context)
        {
            Type[] workflowTypes = context.WorkflowAssembly.GetWorkflowTypes();
            
            if (workflowTypes == null)
                return;

            foreach (Type workflowType in workflowTypes)
            {
                WorkflowNode workflowNode = new WorkflowNode();
                workflowNode.Name = workflowType.Name;
                workflowNode.Text = workflowType.FullName;
                workflowNode.WorkflowType = workflowType;
                workflowNode.SelectedImageIndex = workflowNode.ImageIndex = context.GetImageIndex(typeof(WorkflowComponent), WorkflowNodeImageName);

                context.CurrentTreeNode.Nodes.Add(workflowNode);
                ReflectChildComponents(context.CreateClone(workflowNode));
            }

            if (context.WorkflowAssembly.GetWorkflowTypes().Length == 0)
            {
                TreeNode node = new TreeNode();
                node.Text = "<No Workflows Found>";

                context.CurrentTreeNode.Nodes.Add(node);
            }
        }