private void NotifyChangesToChildExecutors(IWorkflowCoreRuntime workflowCoreRuntime, Activity contextActivity, IList <WorkflowChangeAction> changeActions) { foreach (WorkflowChangeAction action in changeActions) { if (!(action is ActivityChangeAction)) { continue; } CompositeActivity ownerActivity = contextActivity.TraverseDottedPathFromRoot(((ActivityChangeAction)action).OwnerActivityDottedPath) as CompositeActivity; if (ownerActivity == null || !WorkflowChanges.IsActivityExecutable(ownerActivity)) { continue; } ISupportWorkflowChanges compositeActivityExecutor = ActivityExecutors.GetActivityExecutor(ownerActivity) as ISupportWorkflowChanges; if (compositeActivityExecutor == null) { throw new ApplicationException(SR.GetString(SR.Error_WorkflowChangesNotSupported, ownerActivity.GetType().FullName)); } using (workflowCoreRuntime.SetCurrentActivity(ownerActivity)) { using (ActivityExecutionContext executionContext = new ActivityExecutionContext(ownerActivity)) { if (action is AddedActivityAction) { Activity addedActivity = ownerActivity.Activities[((AddedActivityAction)action).Index]; if (WorkflowChanges.IsActivityExecutable(addedActivity)) { addedActivity.OnActivityExecutionContextLoad(executionContext.Activity.RootActivity.WorkflowCoreRuntime); executionContext.InitializeActivity(addedActivity); compositeActivityExecutor.OnActivityAdded(executionContext, addedActivity); } } else if (action is RemovedActivityAction) { RemovedActivityAction removedActivityAction = (RemovedActivityAction)action; if (WorkflowChanges.IsActivityExecutable(removedActivityAction.OriginalRemovedActivity)) { compositeActivityExecutor.OnActivityRemoved(executionContext, removedActivityAction.OriginalRemovedActivity); if (removedActivityAction.OriginalRemovedActivity.ExecutionResult != ActivityExecutionResult.Uninitialized) { removedActivityAction.OriginalRemovedActivity.Uninitialize(executionContext.Activity.RootActivity.WorkflowCoreRuntime); removedActivityAction.OriginalRemovedActivity.SetValue(Activity.ExecutionResultProperty, ActivityExecutionResult.Uninitialized); } removedActivityAction.OriginalRemovedActivity.OnActivityExecutionContextUnload(executionContext.Activity.RootActivity.WorkflowCoreRuntime); removedActivityAction.OriginalRemovedActivity.Dispose(); } } } } } }
private void NotifyChangesToChildExecutors(IWorkflowCoreRuntime workflowCoreRuntime, Activity contextActivity, IList <WorkflowChangeAction> changeActions) { foreach (WorkflowChangeAction action in changeActions) { if (action is ActivityChangeAction) { CompositeActivity activity = contextActivity.TraverseDottedPathFromRoot(((ActivityChangeAction)action).OwnerActivityDottedPath) as CompositeActivity; if ((activity != null) && IsActivityExecutable(activity)) { ISupportWorkflowChanges activityExecutor = ActivityExecutors.GetActivityExecutor(activity) as ISupportWorkflowChanges; if (activityExecutor == null) { throw new ApplicationException(SR.GetString("Error_WorkflowChangesNotSupported", new object[] { activity.GetType().FullName })); } using (workflowCoreRuntime.SetCurrentActivity(activity)) { using (ActivityExecutionContext context = new ActivityExecutionContext(activity)) { if (action is AddedActivityAction) { Activity activity2 = activity.Activities[((AddedActivityAction)action).Index]; if (IsActivityExecutable(activity2)) { activity2.OnActivityExecutionContextLoad(context.Activity.RootActivity.WorkflowCoreRuntime); context.InitializeActivity(activity2); activityExecutor.OnActivityAdded(context, activity2); } } else if (action is RemovedActivityAction) { RemovedActivityAction action2 = (RemovedActivityAction)action; if (IsActivityExecutable(action2.OriginalRemovedActivity)) { activityExecutor.OnActivityRemoved(context, action2.OriginalRemovedActivity); if (action2.OriginalRemovedActivity.ExecutionResult != ActivityExecutionResult.Uninitialized) { action2.OriginalRemovedActivity.Uninitialize(context.Activity.RootActivity.WorkflowCoreRuntime); action2.OriginalRemovedActivity.SetValue(Activity.ExecutionResultProperty, ActivityExecutionResult.Uninitialized); } action2.OriginalRemovedActivity.OnActivityExecutionContextUnload(context.Activity.RootActivity.WorkflowCoreRuntime); action2.OriginalRemovedActivity.Dispose(); } } } } } } } }