public static void Assign(ModelItem selected) { Contract.Requires(selected != null); CompositeService.UpdateModelItem(selected, selected.GetActivity().CreateTaskActivity()); }
private CompositeNode CreateNewNode(CompositeNode parent, ModelItem item, Activity root) { CompositeNode node = null; AssemblyName assembly = null; if (item != null) { assembly = item.GetAssemblyName(); root = CompositeService.GetRootActivity(item.GetActivity()); if (root == null) { return null; } } else { assembly = root.GetAssemblyName(); } if (!AssemblyService.AssemblyIsBuiltIn(assembly)) { node = new CompositeNode(GetDisplayName(item, assembly), assembly, parent, item); node.Activity = root; var subs = WorkflowInspectionServices.GetActivities(node.Activity); foreach (var sub in subs) { var child = CreateNewNode(node, null, sub); child.IfNotNull(c => node.Children.Add(c)); } } return node; }
/// <summary> /// Update model has same reference /// </summary> public static void UpdateReference(ModelItem source) { Contract.Requires(source != null); var sourceKey = GetNodeKey(source); var assemblyName = sourceKey.Name; var needToUpdate = new List<ModelItem>(); var root = source.Root; var tree = CompositeService.GetSubModelItems(root); foreach (var model in tree) { var key = GetNodeKey(model); if (key != null && key.Name == assemblyName && model != source) { needToUpdate.Add(model); } } foreach (var target in needToUpdate) { var copyActivity = source.GetActivity().Clone(); CompositeService.UpdateModelItem(target, copyActivity); } }