/// <summary> /// Customize childshape create to set an initial location for a <see cref="BarkerEntityShape"/> /// </summary> protected override ShapeElement CreateChildShape(ModelElement element) { object barkerEntityPositionsObject; Dictionary <Guid, PointD> barkerEntityPositions; PointD initialLocation; BarkerErModelContainsBinaryAssociation modelContainsAssociation; EntityType barkerEntity; ConceptType conceptType; ObjectType objectType; if (null != (barkerEntity = element as EntityType)) { if (element.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo.TryGetValue(BarkerEntityPositionDictionaryKey, out barkerEntityPositionsObject) && null != (barkerEntityPositions = barkerEntityPositionsObject as Dictionary <Guid, PointD>) && null != (conceptType = EntityTypeIsPrimarilyForConceptType.GetConceptType(barkerEntity)) && null != (objectType = ConceptTypeIsForObjectType.GetObjectType(conceptType)) && barkerEntityPositions.TryGetValue(objectType.Id, out initialLocation)) { return(new BarkerEntityShape( this.Partition, new PropertyAssignment(BarkerEntityShape.AbsoluteBoundsDomainPropertyId, new RectangleD(initialLocation, new SizeD(1, 0.3))))); } } else if (null != (modelContainsAssociation = element as BarkerErModelContainsBinaryAssociation)) { return(new AssociationConnector(Partition)); } return(base.CreateChildShape(element)); }
/// <summary> /// Serializes this <see cref="BarkerERDiagram"/>. /// </summary> /// <param name="writer">A <see cref="T:System.Xml.XmlWriter"/> that will write the custom serialization contents.</param> void IXmlSerializable.WriteXml(XmlWriter writer) { string rvNamespace = BarkerERShapeDomainModel.XmlNamespace; // <BarkerERDiagram> // <BarkerEntityShape ObjectTypeRef="" Location="x, y" /> // ... // </BarkerERDiagram> ISerializationContext serializationContext = ((ISerializationContextHost)Store).SerializationContext; writer.WriteStartElement(BarkerERDiagramElementName, rvNamespace); writer.WriteAttributeString(IdAttributeName, serializationContext.GetIdentifierString(Id)); writer.WriteAttributeString(SubjectRefAttributeName, serializationContext.GetIdentifierString(this.ModelElement.Id)); TypeConverter typeConverter = TypeDescriptor.GetConverter(typeof(PointD)); foreach (ShapeElement shapeElement in this.NestedChildShapes) { BarkerEntityShape barkerEntityShape = shapeElement as BarkerEntityShape; if (barkerEntityShape != null) { ConceptType conceptType; ObjectType objectType; if (null != (conceptType = EntityTypeIsPrimarilyForConceptType.GetConceptType((EntityType)barkerEntityShape.ModelElement)) && null != (objectType = ConceptTypeIsForObjectType.GetObjectType(conceptType))) { writer.WriteStartElement(BarkerEntityShapeElementName, rvNamespace); writer.WriteAttributeString(ObjectTypeRefAttributeName, serializationContext.GetIdentifierString(objectType.Id)); writer.WriteAttributeString(LocationAttributeName, typeConverter.ConvertToInvariantString(barkerEntityShape.Location)); writer.WriteEndElement(); } } } writer.WriteEndElement(); }
private static bool AllStepsMandatory(EntityType entity, IEnumerable <ConceptTypeChild> links) { bool allStepsMandatory = true; ConceptType lastTarget = null; bool firstPass = true; foreach (ConceptTypeChild child in links) { if (!child.IsMandatory) { ConceptTypeAssimilatesConceptType assimilation = child as ConceptTypeAssimilatesConceptType; if (assimilation != null) { // The IsMandatory property applies when stepping parent-to-target, However, stepping target-to-parent // is always considered mandatory. See if we're in this situation. if (firstPass) { lastTarget = EntityTypeIsPrimarilyForConceptType.GetConceptType(entity); } if (lastTarget != null && lastTarget == assimilation.Target) { lastTarget = assimilation.Parent; firstPass = false; continue; } } allStepsMandatory = false; break; } lastTarget = child.Target as ConceptType; firstPass = false; } return(allStepsMandatory); }