public void LoadActivityTree(Activity rootActivity, System.Activities.ActivityInstance rootInstance, List <System.Activities.ActivityInstance> secondaryRootInstances, ActivityExecutor executor) { this.instanceMapping = new Dictionary <Activity, InstanceList>(this.rawDeserializedLists.Length); for (int i = 0; i < this.rawDeserializedLists.Length; i++) { Activity activity; InstanceList list = this.rawDeserializedLists[i]; if (!QualifiedId.TryGetElementFromRoot(rootActivity, list.ActivityId, out activity)) { throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.ActivityInstanceFixupFailed)); } this.instanceMapping.Add(activity, list); list.Load(activity, this); } this.rawDeserializedLists = null; Func <System.Activities.ActivityInstance, ActivityExecutor, bool> callback = new Func <System.Activities.ActivityInstance, ActivityExecutor, bool>(this.OnActivityInstanceLoaded); rootInstance.FixupInstance(null, this, executor); ActivityUtilities.ProcessActivityInstanceTree(rootInstance, executor, callback); if (secondaryRootInstances != null) { foreach (System.Activities.ActivityInstance instance in secondaryRootInstances) { instance.FixupInstance(null, this, executor); ActivityUtilities.ProcessActivityInstanceTree(instance, executor, callback); } } }
public void LoadActivityTree(Activity rootActivity, ActivityInstance rootInstance, List <ActivityInstance> secondaryRootInstances, ActivityExecutor executor) { Fx.Assert(_rawDeserializedLists != null, "We should always have deserialized some lists."); _instanceMapping = new Dictionary <Activity, InstanceList>(_rawDeserializedLists.Length); for (int i = 0; i < _rawDeserializedLists.Length; i++) { InstanceList list = _rawDeserializedLists[i]; Activity activity; if (!QualifiedId.TryGetElementFromRoot(rootActivity, list.ActivityId, out activity)) { throw Microsoft.CoreWf.Internals.FxTrace.Exception.AsError(new InvalidOperationException(SR.ActivityInstanceFixupFailed)); } _instanceMapping.Add(activity, list); list.Load(activity, this); } // We need to null this out once we've recreated the dictionary to avoid // having out of sync data _rawDeserializedLists = null; // then walk our instance list, fixup parent references, and perform basic validation Func <ActivityInstance, ActivityExecutor, bool> processInstanceCallback = new Func <ActivityInstance, ActivityExecutor, bool>(OnActivityInstanceLoaded); rootInstance.FixupInstance(null, this, executor); ActivityUtilities.ProcessActivityInstanceTree(rootInstance, executor, processInstanceCallback); if (secondaryRootInstances != null) { foreach (ActivityInstance instance in secondaryRootInstances) { instance.FixupInstance(null, this, executor); ActivityUtilities.ProcessActivityInstanceTree(instance, executor, processInstanceCallback); } } }