//[SuppressMessage(FxCop.Category.Design, FxCop.Rule.AvoidOutParameters, Justification = "Approved Design. Need to return the map and the block list.")] public static DynamicUpdateMap CreateUpdateMap(ActivityBuilder updatedActivityDefinition, IEnumerable <Activity> disallowUpdateInsideActivities, out IList <ActivityBlockingUpdate> activitiesBlockingUpdate) { if (updatedActivityDefinition == null) { throw FxTrace.Exception.ArgumentNull(nameof(updatedActivityDefinition)); } var originalActivityDefinition = DynamicUpdateInfo.GetOriginalActivityBuilder(updatedActivityDefinition); if (originalActivityDefinition == null) { throw FxTrace.Exception.Argument(nameof(updatedActivityDefinition), SR.MustCallPrepareBeforeFinalize); } Activity originalBuiltRoot = GetDynamicActivity(originalActivityDefinition); Activity updatedBuiltRoot = GetDynamicActivity(updatedActivityDefinition); var result = InternalTryCreateUpdateMap(updatedBuiltRoot, originalBuiltRoot, disallowUpdateInsideActivities, true, out activitiesBlockingUpdate); // Remove the DynamicUpdateMapItems now that the update is finalized Calling // CalculateMapItems is actually an unnecessary perf hit since it calls CacheMetadata // again; but we do it so that Finalize is implemented purely in terms of other public APIs. DynamicUpdateInfo.SetOriginalActivityBuilder(updatedActivityDefinition, null); var mapItems = DynamicUpdateMap.CalculateImplementationMapItems(updatedBuiltRoot); foreach (var matchObject in mapItems.Keys) { DynamicUpdateInfo.SetMapItem(matchObject, null); } return(result); }
private static void InternalPrepareForUpdate(object definitionToBeUpdated, bool forImplementation) { // Clone the definition object clone; using (var reader = new XamlObjectReader(definitionToBeUpdated)) { using var writer = new XamlObjectWriter(reader.SchemaContext); XamlServices.Transform(reader, writer); clone = writer.Result; } // Calculate the match info Set the match info as attached properties so it is // serializable, and available when the user calls CreateUpdateMap IDictionary <object, DynamicUpdateMapItem> mapItems; if (!forImplementation) { DynamicUpdateInfo.SetOriginalDefinition(definitionToBeUpdated, (Activity)clone); mapItems = DynamicUpdateMap.CalculateMapItems((Activity)definitionToBeUpdated); } else { DynamicUpdateInfo.SetOriginalActivityBuilder(definitionToBeUpdated, (ActivityBuilder)clone); mapItems = DynamicUpdateMap.CalculateImplementationMapItems(GetDynamicActivity((ActivityBuilder)definitionToBeUpdated)); } foreach (var objectInfo in mapItems) { DynamicUpdateInfo.SetMapItem(objectInfo.Key, objectInfo.Value); } }