private static void TranslateDiagramObjectHelper( EntityDesignerViewModel viewModel, ModelDiagram.BaseDiagramObject modelDiagramEFObject, EFObject modelObjectToFindViewModel, bool updateShapeElements, UpdateShapeInfoCallback updateShapeInfoCallback) { var diagram = viewModel.GetDiagram(); EFObject diagramEFObject = modelDiagramEFObject; Debug.Assert(diagram != null, "Where is the DSL diagram?"); Debug.Assert(diagramEFObject != null, "Where is the EFObject corresponding to the diagram?"); if (diagram != null && diagramEFObject != null) { var shapeElement = viewModel.ModelXRef.GetExisting(diagramEFObject) as ViewModelDiagram.ShapeElement; if (shapeElement == null) { // find the view model associated with the model EFObject var viewModelElement = viewModel.ModelXRef.GetExisting(modelObjectToFindViewModel); Debug.Assert(viewModelElement != null, "Where is the view model for the model object?"); if (viewModelElement != null) { // get the shape element fromm the view model shapeElement = diagram.FindShape(viewModelElement); Debug.Assert(shapeElement != null, "Where is the DSL ShapeElement for the view model?"); if (shapeElement != null) { // associate the designer model EFObject with the shape element if ((viewModel.ModelXRef.GetExisting(diagramEFObject) == null) && (viewModel.ModelXRef.GetExisting(shapeElement) == null)) { viewModel.ModelXRef.Add(diagramEFObject, shapeElement, viewModel.EditingContext); } } } } // update the shape information for the element if (updateShapeElements && shapeElement != null) { updateShapeInfoCallback(shapeElement); } } }