/// <summary>
        /// Merges the current directory with an additional directory.
        /// </summary>
        /// <param name="data">Directory</param>
        public void Merge(IDomainDataExtensionDirectory data)
        {
            if (!(data is DiagramDomainDataDirectory))
            {
                throw new InvalidOperationException("Can not merge with " + data.ToString());
            }

            DiagramDomainDataDirectory domainData = data as DiagramDomainDataDirectory;

            foreach (KeyValuePair <Guid, Guid> pair in domainData.ClassShapesDependenciesMapping)
            {
                ClassShapesDependenciesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.ParentChildrenShapesMapping)
            {
                ParentChildrenShapesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramChildrenShapesMapping)
            {
                DiagramChildrenShapesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramRootChildrenShapesMapping)
            {
                DiagramRootChildrenShapesMapping.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramRSChildren)
            {
                DiagramRSChildren.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.DiagramMappingRSChildren)
            {
                DiagramMappingRSChildren.Add(pair.Key, pair.Value);
            }

            // class shape mappings
            foreach (KeyValuePair <Guid, List <Guid> > pair in domainData.ClassShapesMapping)
            {
                if (ClassShapesMapping.ContainsKey(pair.Key))
                {
                    ClassShapesMapping[pair.Key].AddRange(pair.Value);
                }
                else
                {
                    ClassShapesMapping.Add(pair.Key, pair.Value);
                }
            }


            foreach (KeyValuePair <Guid, DiagramClassInfo> pair in domainData.DiagramClassInfos)
            {
                DiagramClassInfos.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, ShapeClassInfo> pair in domainData.ShapeClassInfos)
            {
                ShapeClassInfos.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, RelationshipShapeInfo> pair in domainData.RelationshipShapeInfos)
            {
                RelationshipShapeInfos.Add(pair.Key, pair.Value);
            }

            foreach (KeyValuePair <Guid, MappingRelationshipShapeInfo> pair in domainData.MappingRelationshipShapeInfos)
            {
                MappingRelationshipShapeInfos.Add(pair.Key, pair.Value);
            }
        }
        /// <summary>
        /// Process and initialize the contained data.
        /// </summary>
        public void Process()
        {
            DiagramClassInfo[] diagramInfos = GetDiagramClassInfo();
            if (diagramInfos != null)
            {
                foreach (DiagramClassInfo info in diagramInfos)
                {
                    DiagramChildrenShapesMapping.Add(info.DiagramClassType, new List <Guid>());
                    DiagramRootChildrenShapesMapping.Add(info.DiagramClassType, new List <Guid>());
                    DiagramRSChildren.Add(info.DiagramClassType, new List <Guid>());
                    DiagramMappingRSChildren.Add(info.DiagramClassType, new List <Guid>());

                    DiagramClassInfos.Add(info.DiagramClassType, info);
                }
            }

            Guid[] classIds = GetClassesRelevantForSM();
            if (classIds != null)
            {
                foreach (Guid id in classIds)
                {
                    ClassShapesMapping.Add(id, new List <Guid>());
                }
            }

            ShapeClassInfo[] shapeInfos = GetShapeClassInfo();
            if (shapeInfos != null)
            {
                foreach (ShapeClassInfo info in shapeInfos)
                {
                    ShapeClassInfos.Add(info.ShapeClassType, info);
                    ClassShapesMapping[info.DomainClassType].Add(info.ShapeClassType);

                    if (info.UsedInDependencyView)
                    {
                        ClassShapesDependenciesMapping.Add(info.DomainClassType, info.ShapeClassType);
                    }

                    ParentChildrenShapesMapping.Add(info.ShapeClassType, new List <Guid>());

                    DiagramChildrenShapesMapping[info.DiagramClassType].Add(info.ShapeClassType);
                    if (info.ParentShapeClassType == null)
                    {
                        DiagramRootChildrenShapesMapping[info.DiagramClassType].Add(info.ShapeClassType);
                    }
                }
                foreach (ShapeClassInfo info in shapeInfos)
                {
                    if (info.ParentShapeClassType != null)
                    {
                        ParentChildrenShapesMapping[info.ParentShapeClassType.Value].Add(info.ShapeClassType);
                    }
                }
            }

            RelationshipShapeInfo[] rsInfos = GetRelationshipShapeInfo();
            if (rsInfos != null)
            {
                foreach (RelationshipShapeInfo info in rsInfos)
                {
                    RelationshipShapeInfos.Add(info.ShapeClassType, info);
                    ClassShapesMapping[info.DomainClassType].Add(info.ShapeClassType);

                    DiagramRSChildren[info.DiagramClassType].Add(info.ShapeClassType);
                }
            }

            MappingRelationshipShapeInfo[] mrsInfos = GetMappingRelationshipShapeInfo();
            if (rsInfos != null)
            {
                foreach (MappingRelationshipShapeInfo info in mrsInfos)
                {
                    MappingRelationshipShapeInfos.Add(info.ShapeClassType, info);
                    ClassShapesMapping[info.DomainClassType].Add(info.ShapeClassType);

                    DiagramMappingRSChildren[info.DiagramClassType].Add(info.ShapeClassType);
                }
            }
        }