public static void SetToShape(TargetAnchor element, NodeShape newNodeShape)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, TargetAnchorDomainRoleId, newNodeShape);
		}
        /// <summary>
        /// Called whenever elements properties are changed.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            base.ElementPropertyChanged(e);

            if (e.ModelElement == null)
            {
                return;
            }

            if (e.ModelElement.Store.InSerializationTransaction == true)
            {
                return;
            }

            if (e.ModelElement.IsDeleted || e.ModelElement.IsDeleting)
            {
                return;
            }

            SourceAnchor sourceAnchor = e.ModelElement as SourceAnchor;

            if (sourceAnchor != null)
            {
                if (sourceAnchor.LinkShape != null)
                {
                    if (sourceAnchor.LinkShape.IsDeleted || sourceAnchor.LinkShape.IsDeleting)
                    {
                        return;
                    }
                }

                if (e.DomainProperty.Id == Anchor.AbsoluteLocationDomainPropertyId && sourceAnchor.LinkShape != null)
                {
                    if (!sourceAnchor.LinkShape.IsLayoutInProgress)
                    {
                        if (!sourceAnchor.DiscardLocationChange)
                        {
                            sourceAnchor.LinkShape.InternalLayout(FixedGeometryPoints.Source);
                        }
                        else
                        {
                            sourceAnchor.DiscardLocationChange = false;
                        }
                    }
                }
            }

            TargetAnchor targetAnchor = e.ModelElement as TargetAnchor;

            if (targetAnchor != null)
            {
                if (targetAnchor.LinkShape != null)
                {
                    if (targetAnchor.LinkShape.IsDeleted || targetAnchor.LinkShape.IsDeleting)
                    {
                        return;
                    }
                }

                if (e.DomainProperty.Id == Anchor.AbsoluteLocationDomainPropertyId && targetAnchor.LinkShape != null)
                {
                    if (!targetAnchor.LinkShape.IsLayoutInProgress)
                    {
                        if (!targetAnchor.DiscardLocationChange)
                        {
                            targetAnchor.LinkShape.InternalLayout(FixedGeometryPoints.Target);
                        }
                        else
                        {
                            targetAnchor.DiscardLocationChange = false;
                        }
                    }
                }
            }
        }
		/// <summary>
		/// Constructor
		/// Creates a TargetAnchorReferencesToShape link in the same Partition as the given TargetAnchor
		/// </summary>
		/// <param name="source">TargetAnchor to use as the source of the relationship.</param>
		/// <param name="target">NodeShape to use as the target of the relationship.</param>
		public TargetAnchorReferencesToShape(TargetAnchor source, NodeShape target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(TargetAnchorReferencesToShape.TargetAnchorDomainRoleId, source), new DslModeling::RoleAssignment(TargetAnchorReferencesToShape.NodeShapeDomainRoleId, target)}, null)
		{
		}
		public static NodeShape GetToShape(TargetAnchor element)
		{
			return DslModeling::DomainRoleInfo.GetLinkedElement(element, TargetAnchorDomainRoleId) as NodeShape;
		}
		public static void SetTargetAnchor(LinkShape element, TargetAnchor newTargetAnchor)
		{
			DslModeling::DomainRoleInfo.SetLinkedElement(element, LinkShapeDomainRoleId, newTargetAnchor);
		}
		/// <summary>
		/// Constructor
		/// Creates a LinkShapeHasTargetAnchor link in the same Partition as the given LinkShape
		/// </summary>
		/// <param name="source">LinkShape to use as the source of the relationship.</param>
		/// <param name="target">TargetAnchor to use as the target of the relationship.</param>
		public LinkShapeHasTargetAnchor(LinkShape source, TargetAnchor target)
			: base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(LinkShapeHasTargetAnchor.LinkShapeDomainRoleId, source), new DslModeling::RoleAssignment(LinkShapeHasTargetAnchor.TargetAnchorDomainRoleId, target)}, null)
		{
		}
		private static void WriteChildElements(DslModeling::SerializationContext serializationContext, TargetAnchor element, global::System.Xml.XmlWriter writer)
		{
			// TargetAnchorReferencesToShape
			TargetAnchorReferencesToShape theTargetAnchorReferencesToShapeInstance = TargetAnchorReferencesToShape.GetLinkToToShape(element);
			if (!serializationContext.Result.Failed && theTargetAnchorReferencesToShapeInstance != null)
			{
				writer.WriteStartElement("toShape");
				DslModeling::DomainClassXmlSerializer relSerializer = serializationContext.Directory.GetSerializer(theTargetAnchorReferencesToShapeInstance.GetDomainClass().Id);
				global::System.Diagnostics.Debug.Assert(relSerializer != null, "Cannot find serializer for " + theTargetAnchorReferencesToShapeInstance.GetDomainClass().Name + "!");
				relSerializer.Write(serializationContext, theTargetAnchorReferencesToShapeInstance, writer);
				writer.WriteEndElement();
			}
	
		}
		private static void ReadTargetAnchorReferencesToShapeInstance(DslModeling::SerializationContext serializationContext, TargetAnchor element, global::System.Xml.XmlReader reader)
		{
			if (DslModeling::DomainRoleInfo.GetElementLinks<TargetAnchorReferencesToShape> (element, TargetAnchorReferencesToShape.TargetAnchorDomainRoleId).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 newTargetAnchorReferencesToShapeSerializer = serializationContext.Directory.GetSerializer(TargetAnchorReferencesToShape.DomainClassId);
				global::System.Diagnostics.Debug.Assert(newTargetAnchorReferencesToShapeSerializer != null, "Cannot find serializer for TargetAnchorReferencesToShape!");
				TargetAnchorReferencesToShape newTargetAnchorReferencesToShape = newTargetAnchorReferencesToShapeSerializer.TryCreateInstance (serializationContext, reader, element.Partition) as TargetAnchorReferencesToShape;
				if (newTargetAnchorReferencesToShape != null)
				{
					DslModeling::DomainRoleInfo.SetRolePlayer (newTargetAnchorReferencesToShape, TargetAnchorReferencesToShape.TargetAnchorDomainRoleId, element);
					DslModeling::DomainClassXmlSerializer targetSerializer = serializationContext.Directory.GetSerializer (newTargetAnchorReferencesToShape.GetDomainClass().Id);	
					global::System.Diagnostics.Debug.Assert (targetSerializer != null, "Cannot find serializer for " + newTargetAnchorReferencesToShape.GetDomainClass().Name + "!");
					targetSerializer.Read(serializationContext, newTargetAnchorReferencesToShape, reader);
					break;	// Only allow one instance.
				}
				else
				{	// Maybe the relationship is serialized in short-form by mistake.
					DslModeling::DomainClassXmlSerializer newNodeShapeMonikerOfTargetAnchorReferencesToShapeSerializer = serializationContext.Directory.GetSerializer(NodeShape.DomainClassId);
					global::System.Diagnostics.Debug.Assert(newNodeShapeMonikerOfTargetAnchorReferencesToShapeSerializer != null, "Cannot find serializer for NodeShape!");
					DslModeling::Moniker newNodeShapeMonikerOfTargetAnchorReferencesToShape = newNodeShapeMonikerOfTargetAnchorReferencesToShapeSerializer.TryCreateMonikerInstance(serializationContext, reader, element, TargetAnchorReferencesToShape.DomainClassId, element.Partition);
					if (newNodeShapeMonikerOfTargetAnchorReferencesToShape != null)
					{
						TestDslDefinitionSerializationBehaviorSerializationMessages.ExpectingFullFormRelationship(serializationContext, reader, typeof(TargetAnchorReferencesToShape));
						new TargetAnchorReferencesToShape(element.Partition, new DslModeling::RoleAssignment(TargetAnchorReferencesToShape.TargetAnchorDomainRoleId, element), new DslModeling::RoleAssignment(TargetAnchorReferencesToShape.NodeShapeDomainRoleId, newNodeShapeMonikerOfTargetAnchorReferencesToShape));
						DslModeling::SerializationUtilities.Skip(reader);	// Moniker contains no child XML elements, so just skip.
						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 TargetAnchor instance that will get the deserialized data.</param>
		private static void ReadChildElements(DslModeling::SerializationContext serializationContext, TargetAnchor element, global::System.Xml.XmlReader reader)
		{
			if (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element)
			{
				if (string.Compare(reader.LocalName, "toShape", 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 <toShape>
						ReadTargetAnchorReferencesToShapeInstance(serializationContext, element, reader);
						DslModeling::SerializationUtilities.Skip(reader);  // Skip the close tag of </toShape>
					}
				}
			}
		}