private void InitializeComponent() { this.CanModifyActivities = true; System.Workflow.Runtime.CorrelationToken correlationtoken1 = new System.Workflow.Runtime.CorrelationToken(); System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind(); System.Workflow.ComponentModel.WorkflowParameterBinding workflowparameterbinding1 = new System.Workflow.ComponentModel.WorkflowParameterBinding(); System.Workflow.Runtime.CorrelationToken correlationtoken2 = new System.Workflow.Runtime.CorrelationToken(); System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind(); System.Workflow.ComponentModel.WorkflowParameterBinding workflowparameterbinding2 = new System.Workflow.ComponentModel.WorkflowParameterBinding(); this.handleExternalEvent = new System.Workflow.Activities.HandleExternalEventActivity(); this.initializeCorrelation = new System.Workflow.Activities.CallExternalMethodActivity(); // // handleExternalEvent // correlationtoken1.Name = "token"; correlationtoken1.OwnerActivityName = "WaitForExternalEventActivity"; this.handleExternalEvent.CorrelationToken = correlationtoken1; this.handleExternalEvent.EventName = "OnExternalEvent"; this.handleExternalEvent.InterfaceType = typeof(ILoveSharePoint.Workflow.Activities.IWaitForExternalEventService); this.handleExternalEvent.Name = "handleExternalEvent"; activitybind1.Name = "WaitForExternalEventActivity"; activitybind1.Path = "ExternalEventArgs"; workflowparameterbinding1.ParameterName = "e"; workflowparameterbinding1.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1))); this.handleExternalEvent.ParameterBindings.Add(workflowparameterbinding1); this.handleExternalEvent.Invoked += new System.EventHandler <System.Workflow.Activities.ExternalDataEventArgs>(this.Invoked); this.handleExternalEvent.InterfaceType = typeof(ILoveSharePoint.Workflow.Activities.IWaitForExternalEventService); // // initializeCorrelation // correlationtoken2.Name = "token"; correlationtoken2.OwnerActivityName = "WaitForExternalEventActivity"; this.initializeCorrelation.CorrelationToken = correlationtoken2; this.initializeCorrelation.InterfaceType = typeof(ILoveSharePoint.Workflow.Activities.IWaitForExternalEventService); this.initializeCorrelation.MethodName = "Initialize"; this.initializeCorrelation.Name = "initializeCorrelation"; activitybind2.Name = "WaitForExternalEventActivity"; activitybind2.Path = "CorrelationIdentifier"; workflowparameterbinding2.ParameterName = "correlationToken"; workflowparameterbinding2.SetBinding(System.Workflow.ComponentModel.WorkflowParameterBinding.ValueProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2))); this.initializeCorrelation.ParameterBindings.Add(workflowparameterbinding2); this.initializeCorrelation.InterfaceType = typeof(ILoveSharePoint.Workflow.Activities.IWaitForExternalEventService); // // WaitForExternalEventActivity // this.Activities.Add(this.initializeCorrelation); this.Activities.Add(this.handleExternalEvent); this.Name = "WaitForExternalEventActivity"; this.CanModifyActivities = false; }
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)); } }