public static ClientApplication GetClientApplication(Proxy element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, ProxyDomainRoleId) as ClientApplication; }
public static void SetClientApplication(Proxy element, ClientApplication newClientApplication) { DslModeling::DomainRoleInfo.SetLinkedElement(element, ProxyDomainRoleId, newClientApplication); }
public static void SetEndpoint(Proxy element, Endpoint newEndpoint) { DslModeling::DomainRoleInfo.SetLinkedElement(element, ProxyDomainRoleId, newEndpoint); }
/// <summary> /// Constructor /// Creates a ClientApplicationHasProxies link in the same Partition as the given ClientApplication /// </summary> /// <param name="source">ClientApplication to use as the source of the relationship.</param> /// <param name="target">Proxy to use as the target of the relationship.</param> public ClientApplicationHasProxies(ClientApplication source, Proxy target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ClientApplicationHasProxies.ClientApplicationDomainRoleId, source), new DslModeling::RoleAssignment(ClientApplicationHasProxies.ProxyDomainRoleId, target)}, null) { }
public static Endpoint GetEndpoint(Proxy element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, ProxyDomainRoleId) as Endpoint; }
/// <summary> /// Constructor /// Creates a ProxyReferencesEndpoint link in the same Partition as the given Proxy /// </summary> /// <param name="source">Proxy to use as the source of the relationship.</param> /// <param name="target">Endpoint to use as the target of the relationship.</param> public ProxyReferencesEndpoint(Proxy source, Endpoint target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ProxyReferencesEndpoint.ProxyDomainRoleId, source), new DslModeling::RoleAssignment(ProxyReferencesEndpoint.EndpointDomainRoleId, target)}, null) { }
private static void WriteChildElements(DslModeling::SerializationContext serializationContext, Proxy element, global::System.Xml.XmlWriter writer) { // ProxyReferencesEndpoint ProxyReferencesEndpoint theProxyReferencesEndpointInstance = ProxyReferencesEndpoint.GetLinkToEndpoint(element); if (!serializationContext.Result.Failed && theProxyReferencesEndpointInstance != null) { DslModeling::DomainRelationshipXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(ProxyReferencesEndpoint.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer; global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for ProxyReferencesEndpoint!"); writer.WriteStartElement("endpoint"); global::System.Type typeofProxyReferencesEndpoint = typeof(ProxyReferencesEndpoint); if (theProxyReferencesEndpointInstance.GetType() != typeofProxyReferencesEndpoint) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(theProxyReferencesEndpointInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + theProxyReferencesEndpointInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, theProxyReferencesEndpointInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = theProxyReferencesEndpointInstance.Endpoint; DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer(targetElement.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(targetSerializer != null, "Cannot find serializer for " + targetElement.GetDomainClass().Name + "!"); targetSerializer.WriteMoniker(serializationContext, targetElement, writer, element, relSerializer); } writer.WriteEndElement(); } }
private static void ReadProxyReferencesEndpointInstance(DslModeling::SerializationContext serializationContext, Proxy element, global::System.Xml.XmlReader reader) { if (DslModeling::DomainRoleInfo.GetElementLinks<ProxyReferencesEndpoint> (element, ProxyReferencesEndpoint.ProxyDomainRoleId).Count > 0) { // Only allow one instance, which already exists, so skip everything DslModeling::SerializationUtilities.Skip(reader); // Moniker contains no child XML elements, so just skip. return; } while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { DslModeling::DomainClassXmlSerializer newEndpointMonikerOfProxyReferencesEndpointSerializer = serializationContext.Directory.GetSerializer(Endpoint.DomainClassId); global::System.Diagnostics.Debug.Assert(newEndpointMonikerOfProxyReferencesEndpointSerializer != null, "Cannot find serializer for Endpoint!"); DslModeling::Moniker newEndpointMonikerOfProxyReferencesEndpoint = newEndpointMonikerOfProxyReferencesEndpointSerializer.TryCreateMonikerInstance(serializationContext, reader, element, ProxyReferencesEndpoint.DomainClassId, element.Partition); if (newEndpointMonikerOfProxyReferencesEndpoint != null) { new ProxyReferencesEndpoint(element.Partition, new DslModeling::RoleAssignment(ProxyReferencesEndpoint.ProxyDomainRoleId, element), new DslModeling::RoleAssignment(ProxyReferencesEndpoint.EndpointDomainRoleId, newEndpointMonikerOfProxyReferencesEndpoint)); DslModeling::SerializationUtilities.Skip(reader); // Moniker contains no child XML elements, so just skip. break; // Only allow one instance. } else { global::System.Type typeofProxyReferencesEndpoint = typeof(ProxyReferencesEndpoint); DslModeling::DomainRelationshipXmlSerializer newProxyReferencesEndpointSerializer = serializationContext.Directory.GetSerializer(ProxyReferencesEndpoint.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer; global::System.Diagnostics.Debug.Assert(newProxyReferencesEndpointSerializer != null, "Cannot find serializer for ProxyReferencesEndpoint!"); ProxyReferencesEndpoint newProxyReferencesEndpoint = newProxyReferencesEndpointSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ProxyReferencesEndpoint; if (newProxyReferencesEndpoint != null) { if (newProxyReferencesEndpoint.GetType() == typeofProxyReferencesEndpoint) { // The relationship should be serialized in short-form. HostDesignerSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(ProxyReferencesEndpoint)); } DslModeling::DomainRoleInfo.SetRolePlayer (newProxyReferencesEndpoint, ProxyReferencesEndpoint.ProxyDomainRoleId, element); DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newProxyReferencesEndpoint.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newProxyReferencesEndpoint.GetDomainClass().Name + "!"); targetSerializer.Read(serializationContext, newProxyReferencesEndpoint, reader); break; // Only allow one instance. } 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 Proxy instance that will get the deserialized data.</param> private static void ReadChildElements(DslModeling::SerializationContext serializationContext, Proxy element, global::System.Xml.XmlReader reader) { if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { if (string.Compare(reader.LocalName, "endpoint", 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 <endpoint> ReadProxyReferencesEndpointInstance(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </endpoint> } } } }