public static void SetServiceDescription(Endpoint element, ServiceDescription newServiceDescription) { DslModeling::DomainRoleInfo.SetLinkedElement(element, EndpointDomainRoleId, newServiceDescription); }
public static DslModeling::LinkedElementCollection<Endpoint> GetEndpoints(ServiceDescription element) { return GetRoleCollection<DslModeling::LinkedElementCollection<Endpoint>, Endpoint>(element, ServiceDescriptionDomainRoleId); }
public static void SetHostApplication(ServiceDescription element, HostApplication newHostApplication) { DslModeling::DomainRoleInfo.SetLinkedElement(element, ServiceDescriptionDomainRoleId, newHostApplication); }
/// <summary> /// Constructor /// Creates a ServiceDescriptionHasEndpoints link in the same Partition as the given ServiceDescription /// </summary> /// <param name="source">ServiceDescription to use as the source of the relationship.</param> /// <param name="target">Endpoint to use as the target of the relationship.</param> public ServiceDescriptionHasEndpoints(ServiceDescription source, Endpoint target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(ServiceDescriptionHasEndpoints.ServiceDescriptionDomainRoleId, source), new DslModeling::RoleAssignment(ServiceDescriptionHasEndpoints.EndpointDomainRoleId, target)}, null) { }
public static HostApplication GetHostApplication(ServiceDescription element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, ServiceDescriptionDomainRoleId) as HostApplication; }
/// <summary> /// Constructor /// Creates a HostApplicationHasServiceDescriptions link in the same Partition as the given HostApplication /// </summary> /// <param name="source">HostApplication to use as the source of the relationship.</param> /// <param name="target">ServiceDescription to use as the target of the relationship.</param> public HostApplicationHasServiceDescriptions(HostApplication source, ServiceDescription target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(HostApplicationHasServiceDescriptions.HostApplicationDomainRoleId, source), new DslModeling::RoleAssignment(HostApplicationHasServiceDescriptions.ServiceDescriptionDomainRoleId, target)}, null) { }
private static void WriteChildElements(DslModeling::SerializationContext serializationContext, ServiceDescription element, global::System.Xml.XmlWriter writer) { // ServiceDescriptionHasEndpoints global::System.Collections.ObjectModel.ReadOnlyCollection<ServiceDescriptionHasEndpoints> allServiceDescriptionHasEndpointsInstances = ServiceDescriptionHasEndpoints.GetLinksToEndpoints(element); if (!serializationContext.Result.Failed && allServiceDescriptionHasEndpointsInstances.Count > 0) { writer.WriteStartElement("endpoints"); global::System.Type typeofServiceDescriptionHasEndpoints = typeof(ServiceDescriptionHasEndpoints); foreach (ServiceDescriptionHasEndpoints eachServiceDescriptionHasEndpointsInstance in allServiceDescriptionHasEndpointsInstances) { if (serializationContext.Result.Failed) break; if (eachServiceDescriptionHasEndpointsInstance.GetType() != typeofServiceDescriptionHasEndpoints) { // Derived relationships will be serialized in full-form. DslModeling::DomainClassXmlSerializer derivedRelSerializer = serializationContext.Directory.GetSerializer(eachServiceDescriptionHasEndpointsInstance.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert(derivedRelSerializer != null, "Cannot find serializer for " + eachServiceDescriptionHasEndpointsInstance.GetDomainClass().Name + "!"); derivedRelSerializer.Write(serializationContext, eachServiceDescriptionHasEndpointsInstance, writer); } else { // No need to serialize the relationship itself, just serialize the role-player directly. DslModeling::ModelElement targetElement = eachServiceDescriptionHasEndpointsInstance.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.Write(serializationContext, targetElement, writer); } } writer.WriteEndElement(); } }
/// <summary> /// Reads all instances of relationship ServiceDescriptionHasEndpoints. /// </summary> /// <remarks> /// The caller will position the reader at the open tag of the first XML element inside the relationship tag, so it can be /// either the first instance, or a bogus tag. This method will deserialize all instances and ignore all bogus tags. When the /// method returns, the reader will be positioned at the end tag of the relationship (or EOF if somehow that happens). /// </remarks> /// <param name="serializationContext">Serialization context.</param> /// <param name="element">In-memory ServiceDescription instance that will get the deserialized data.</param> /// <param name="reader">XmlReader to read serialized data from.</param> private static void ReadServiceDescriptionHasEndpointsInstances(DslModeling::SerializationContext serializationContext, ServiceDescription element, global::System.Xml.XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { DslModeling::DomainClassXmlSerializer newEndpointOfServiceDescriptionHasEndpointsSerializer = serializationContext.Directory.GetSerializer(Endpoint.DomainClassId); global::System.Diagnostics.Debug.Assert(newEndpointOfServiceDescriptionHasEndpointsSerializer != null, "Cannot find serializer for Endpoint!"); Endpoint newEndpointOfServiceDescriptionHasEndpoints = newEndpointOfServiceDescriptionHasEndpointsSerializer.TryCreateInstance(serializationContext, reader, element.Partition) as Endpoint; if (newEndpointOfServiceDescriptionHasEndpoints != null) { element.Endpoints.Add(newEndpointOfServiceDescriptionHasEndpoints); DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newEndpointOfServiceDescriptionHasEndpoints.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newEndpointOfServiceDescriptionHasEndpoints.GetDomainClass().Name + "!"); targetSerializer.Read(serializationContext, newEndpointOfServiceDescriptionHasEndpoints, reader); } else { global::System.Type typeofServiceDescriptionHasEndpoints = typeof(ServiceDescriptionHasEndpoints); DslModeling::DomainRelationshipXmlSerializer newServiceDescriptionHasEndpointsSerializer = serializationContext.Directory.GetSerializer(ServiceDescriptionHasEndpoints.DomainClassId) as DslModeling::DomainRelationshipXmlSerializer; global::System.Diagnostics.Debug.Assert(newServiceDescriptionHasEndpointsSerializer != null, "Cannot find serializer for ServiceDescriptionHasEndpoints!"); ServiceDescriptionHasEndpoints newServiceDescriptionHasEndpoints = newServiceDescriptionHasEndpointsSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as ServiceDescriptionHasEndpoints; if (newServiceDescriptionHasEndpoints != null) { if (newServiceDescriptionHasEndpoints.GetType() == typeofServiceDescriptionHasEndpoints) { // The relationship should be serialized in short-form. HostDesignerSerializationBehaviorSerializationMessages.ExpectingShortFormRelationship(serializationContext, reader, typeof(ServiceDescriptionHasEndpoints)); } DslModeling::DomainRoleInfo.SetRolePlayer (newServiceDescriptionHasEndpoints, ServiceDescriptionHasEndpoints.ServiceDescriptionDomainRoleId, element); DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newServiceDescriptionHasEndpoints.GetDomainClass().Id); global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newServiceDescriptionHasEndpoints.GetDomainClass().Name + "!"); targetSerializer.Read(serializationContext, newServiceDescriptionHasEndpoints, reader); } 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 ServiceDescription instance that will get the deserialized data.</param> private static void ReadChildElements(DslModeling::SerializationContext serializationContext, ServiceDescription element, global::System.Xml.XmlReader reader) { if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { if (string.Compare(reader.LocalName, "endpoints", 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 <endpoints> ReadServiceDescriptionHasEndpointsInstances(serializationContext, element, reader); DslModeling::SerializationUtilities.Skip(reader); // Skip the close tag of </endpoints> } } } }