public int CompareTo(object obj)
        {
            if (null == obj)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            DiagramLibraryNode node = obj as DiagramLibraryNode;

            if (null == node)
            {
                throw new ArgumentException();
            }

            int comparePaths = Path.CompareTo(node.Path);

            if (comparePaths != 0)
            {
                return(comparePaths);
            }
            else
            {
                return(Name.CompareTo(node.Name));
            }
        }
Beispiel #2
0
        public void Read(XmlReader xmlReader)
        {
            if (null == xmlReader)
            {
                throw new ArgumentNullException(nameof(xmlReader));
            }

            using (xmlReader)
            {
                do
                {
                    if (xmlReader.IsStartElement())
                    {
                        switch (xmlReader.Name)
                        {
                        case "diagrams":
                            DiagramLibraryNode node = new DiagramLibraryNode(Style, xmlReader.ReadSubtree());
                            AddNode(node);
                            break;

                        case "style":
                            Style.Read(xmlReader.ReadSubtree());
                            break;
                        }
                    }
                } while (xmlReader.Read());
            }
        }
Beispiel #3
0
        public void Clone(string path, string name, string newName)
        {
            if (StringUtils.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (StringUtils.IsNullOrWhiteSpace(newName))
            {
                throw new ArgumentNullException(nameof(newName));
            }

            path = PathUtils.Clean(path);

            name    = name.Trim();
            newName = newName.Trim();

            if (name != newName)
            {
                if (TryGetNode(path, name, out DiagramLibraryNode node))
                {
                    DiagramLibraryNode clonedNode = node.Clone();
                    clonedNode.Name = newName;
                    AddNode(clonedNode);
                }
                else
                {
                    throw new DiagramCollectionNotFoundException(this, path, name);
                }
            }
        }
Beispiel #4
0
        public DiagramCollection Add(string path, string name)
        {
            DiagramLibraryNode node = new DiagramLibraryNode(Style, path, name);

            AddNode(node);
            return(node.DiagramCollection);
        }
        public DiagramLibraryNode Clone()
        {
            DiagramLibraryNode clone = new DiagramLibraryNode(DiagramCollection.Style.Parent, Path, Name)
            {
                DiagramCollection = DiagramCollection.Clone()
            };

            return(clone);
        }
Beispiel #6
0
        private void AddNode(DiagramLibraryNode node)
        {
            if (null == node)
            {
                throw new ArgumentNullException(nameof(node));
            }

            string path = node.Path;
            string name = node.Name;

            if (TryGetNode(path, name, out DiagramLibraryNode existingNode))
            {
                throw new DiagramCollectionNameAlreadyExistsException(this, path, name);
            }

            ListUtils.SortedInsert <DiagramLibraryNode>(_nodes, node);
        }
Beispiel #7
0
        private bool TryGetNode(string path, string name, out DiagramLibraryNode diagramLibraryNode)
        {
            if (StringUtils.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            path = PathUtils.Clean(path);
            name = name.Trim();

            foreach (DiagramLibraryNode node in _nodes)
            {
                if (node.Name == name && node.Path == path)
                {
                    diagramLibraryNode = node;
                    return(true);
                }
            }

            diagramLibraryNode = null;
            return(false);
        }