/// <summary> /// Constructor /// Creates a ProcessHasSubProcess link in the same Partition as the given Process /// </summary> /// <param name="source">Process to use as the source of the relationship.</param> /// <param name="target">SubProcessElement to use as the target of the relationship.</param> public ProcessHasSubProcess(Process source, SubProcessElement target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ProcessHasSubProcess.ProcessDomainRoleId, source), new DslModeling::RoleAssignment(ProcessHasSubProcess.ElementDomainRoleId, target)}, null) { }
public static DslModeling::LinkedElementCollection<SubProcessElement> GetTargets(SubProcessElement element) { return GetRoleCollection<DslModeling::LinkedElementCollection<SubProcessElement>, SubProcessElement>(element, SourceDomainRoleId); }
public static void SetProcess(SubProcessElement element, Process newProcess) { DslModeling::DomainRoleInfo.SetLinkedElement(element, ElementDomainRoleId, newProcess); }
/// <summary> /// Constructor /// Creates a SubProcessElementReferencesTargets link in the same Partition as the given SubProcessElement /// </summary> /// <param name="source">SubProcessElement to use as the source of the relationship.</param> /// <param name="target">SubProcessElement to use as the target of the relationship.</param> public SubProcessElementReferencesTargets(SubProcessElement source, SubProcessElement target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(SubProcessElementReferencesTargets.SourceDomainRoleId, source), new DslModeling::RoleAssignment(SubProcessElementReferencesTargets.TargetDomainRoleId, target)}, null) { }
public static Process GetProcess(SubProcessElement element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, ElementDomainRoleId) as Process; }
public static void SetAddedSubProcessReference(ModelBusReference subProcessReference, string subProcessName, ModelBusReference processReference, SubProcessElement subProcessElement) { IModelBus parentModelBus = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SModelBus)) as IModelBus; ModelBusReference subProcessElementReference = null; using (CloudCoreArchitectProcessOverviewAdapter adapter = parentModelBus.CreateAdapter(processReference) as CloudCoreArchitectProcessOverviewAdapter) { subProcessElementReference = adapter.GetElementReference(subProcessElement); } IModelBus modelBus = subProcessReference.ModelBus; using (Architect.ModelBusAdapters.CloudCoreArchitectSubProcessAdapter adapter = modelBus.CreateAdapter(subProcessReference) as Architect.ModelBusAdapters.CloudCoreArchitectSubProcessAdapter) { var subProcess = ((adapter.GetDefaultView() as StandardVsModelingDiagramView).Diagram).ModelElement as SubProcess; using (Transaction t = subProcess.Store.TransactionManager.BeginTransaction("update subprocess reference to subprocess file")) { subProcess.SetLocks(Locks.None); subProcess.ProcessOverviewSubProcessRef = subProcessElementReference; subProcess.SetLocks(Locks.Delete | Locks.Add | Locks.Move | Locks.Properties); t.Commit(); } } }
private static void WriteChildElements(DslModeling::SerializationContext serializationContext, SubProcessElement element, global::System.Xml.XmlWriter writer) { // SubProcessElementReferencesTargets global::System.Collections.ObjectModel.ReadOnlyCollection<SubProcessElementReferencesTargets> allSubProcessElementReferencesTargetsInstances = SubProcessElementReferencesTargets.GetLinksToTargets(element); if (!serializationContext.Result.Failed && allSubProcessElementReferencesTargetsInstances.Count > 0) { writer.WriteStartElement("targets"); foreach (SubProcessElementReferencesTargets eachSubProcessElementReferencesTargetsInstance in allSubProcessElementReferencesTargetsInstances) { if (serializationContext.Result.Failed) break; DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(eachSubProcessElementReferencesTargetsInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + eachSubProcessElementReferencesTargetsInstance.GetDomainClass().Name + "!"); relSerializer.Write(serializationContext, eachSubProcessElementReferencesTargetsInstance, writer); } writer.WriteEndElement(); } }
private static void ReadSubProcessElementReferencesTargetsInstances(DslModeling::SerializationContext serializationContext, SubProcessElement element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { DslModeling::DomainClassXmlSerializer newSubProcessElementReferencesTargetsSerializer = serializationContext.Directory.GetSerializer(SubProcessElementReferencesTargets.DomainClassId); global::System.Diagnostics.Debug.Assert(newSubProcessElementReferencesTargetsSerializer != null, "Cannot find serializer for SubProcessElementReferencesTargets!"); SubProcessElementReferencesTargets newSubProcessElementReferencesTargets = newSubProcessElementReferencesTargetsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as SubProcessElementReferencesTargets; if (newSubProcessElementReferencesTargets != null) { DslModeling::DomainRoleInfo.SetRolePlayer (newSubProcessElementReferencesTargets, SubProcessElementReferencesTargets.SourceDomainRoleId, element); DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newSubProcessElementReferencesTargets.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newSubProcessElementReferencesTargets.GetDomainClass().Name + "!"); targetSerializer.Read(serializationContext, newSubProcessElementReferencesTargets, reader); } else { // Maybe the relationship is serialized in short-form by mistake. DslModeling::DomainClassXmlSerializer newSubProcessElementMonikerOfSubProcessElementReferencesTargetsSerializer = serializationContext.Directory.GetSerializer(SubProcessElement.DomainClassId); global::System.Diagnostics.Debug.Assert(newSubProcessElementMonikerOfSubProcessElementReferencesTargetsSerializer != null, "Cannot find serializer for SubProcessElement!"); DslModeling::Moniker newSubProcessElementMonikerOfSubProcessElementReferencesTargets = newSubProcessElementMonikerOfSubProcessElementReferencesTargetsSerializer.TryCreateMonikerInstance(serializationContext, reader, element, SubProcessElementReferencesTargets.DomainClassId, element.Partition); if (newSubProcessElementMonikerOfSubProcessElementReferencesTargets != null) { CloudCoreArchitectProcessOverviewSerializationBehaviorSerializationMessages.ExpectingFullFormRelationship(serializationContext, reader, typeof(SubProcessElementReferencesTargets)); new SubProcessElementReferencesTargets(element.Partition, new DslModeling::RoleAssignment(SubProcessElementReferencesTargets.SourceDomainRoleId, element), new DslModeling::RoleAssignment(SubProcessElementReferencesTargets.TargetDomainRoleId, newSubProcessElementMonikerOfSubProcessElementReferencesTargets)); DslModeling::SerializationUtilities.Skip(reader); // Moniker contains no child XML elements, so just skip. } else { // Unknown element, skip. DslModeling::SerializationUtilities.Skip(reader); } } } }
/// <summary> /// This method deserializes all child model elements. /// </summary> /// <remarks> /// The caller will position the reader at the open tag of the first child XML element to deserialized. /// This method will read as many child elements as it can. It returns under three circumstances: /// 1) When an unknown child XML element is encountered. In this case, this method will position the reader at the /// open tag of the unknown element. This implies that if the first child XML element is unknown, this method /// should return immediately and do nothing. /// 2) When all child XML elemnets are read. In this case, the reader will be positioned at the end tag of the parent element. /// 3) EOF. /// </remarks> /// <param name="serializationContext">Serialization context.</param> /// <param name="reader">XmlReader to read serialized data from.</param> /// <param name="element">In-memory SubProcessElement instance that will get the deserialized data.</param> private static void ReadChildElements(DslModeling::SerializationContext serializationContext, SubProcessElement element, global::System.Xml.XmlReader reader) { if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { if (string.Compare(reader.LocalName, "targets", global::System.StringComparison.CurrentCulture) == 0) { if (reader.IsEmptyElement) { // No instance of this relationship, just skip DslModeling::SerializationUtilities.Skip(reader); } else { DslModeling::SerializationUtilities.SkipToFirstChild(reader); // Skip the open tag of <targets> ReadSubProcessElementReferencesTargetsInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </targets> } } } }