Exemplo n.º 1
0
        public override BuildTopicTocInfo Find(string name, bool recursive)
        {
            if (String.Equals(name, this.Name, StringComparison.OrdinalIgnoreCase))
            {
                return(this);
            }
            if (_listTopics != null && _listTopics.Count != 0)
            {
                BuildTopicTocInfo foundTopic = this[name];
                if (foundTopic != null)
                {
                    return(foundTopic);
                }

                if (recursive)
                {
                    for (int i = 0; i < _listTopics.Count; i++)
                    {
                        foundTopic = _listTopics[i].Find(name, recursive);
                        if (foundTopic != null)
                        {
                            break;
                        }
                    }
                }

                return(foundTopic);
            }

            return(null);
        }
Exemplo n.º 2
0
 public BuildTopicTocInfo(BuildTopicTocInfo source)
     : base(source)
 {
     _source     = source._source;
     _container  = source._container;
     _parent     = source._parent;
     _listTopics = source._listTopics;
 }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            BuildTopicTocInfo other = obj as BuildTopicTocInfo;

            if (other == null)
            {
                return(false);
            }

            return(this.Equals(other));
        }
Exemplo n.º 4
0
        public BuildTopicTocInfo(string name, string source, BuildTopicTocInfo parent)
            : base(name)
        {
            if (String.IsNullOrEmpty(source))
            {
                source = Guid.NewGuid().ToString();
            }

            _source = source;
            _parent = parent;
        }
Exemplo n.º 5
0
        public void Add(BuildTopicTocInfo item)
        {
            if (item == null)
            {
                return;
            }

            if (_listTopics == null)
            {
                _listTopics = new BuildKeyedList <BuildTopicTocInfo>();
            }

            _listTopics.Add(item);
        }
Exemplo n.º 6
0
        public void Insert(int index, BuildTopicTocInfo item)
        {
            if (item == null)
            {
                return;
            }

            if (_listTopics == null)
            {
                _listTopics = new BuildKeyedList <BuildTopicTocInfo>();
            }

            _listTopics.Insert(index, item);
        }
Exemplo n.º 7
0
        public int IndexOf(BuildTopicTocInfo item)
        {
            if (item == null)
            {
                return(-1);
            }

            if (_listTopics != null && _listTopics.Count != 0)
            {
                return(_listTopics.IndexOf(item));
            }

            return(-1);
        }
Exemplo n.º 8
0
        public override BuildTocInfo Clone()
        {
            BuildTopicTocInfo item = new BuildTopicTocInfo(this);

            if (this.Name != null)
            {
                item.Name = String.Copy(this.Name);
            }
            if (_source != null)
            {
                item._source = String.Copy(_source);
            }

            return(item);
        }
Exemplo n.º 9
0
        public void Add(BuildTopicTocInfo item)
        {
            if (item == null || String.IsNullOrEmpty(item.Name))
            {
                return;
            }

            if (_relatedTopics.Contains(item.Name))
            {
                _relatedTopics.Insert(_relatedTopics.Dictionary[item.Name], item);
            }
            else
            {
                _relatedTopics.Add(item);
            }
        }
Exemplo n.º 10
0
        public BuildTopicTocInfo this[string itemName]
        {
            get
            {
                if (String.IsNullOrEmpty(itemName))
                {
                    return(null);
                }

                BuildTopicTocInfo tocInfo = null;
                if (_relatedTopics != null && _relatedTopics.Count != 0)
                {
                    tocInfo = _relatedTopics[itemName];
                    if (tocInfo != null)
                    {
                        return(tocInfo);
                    }
                }
                if (_listItems == null || _listItems.Count == 0)
                {
                    return(null);
                }
                for (int i = 0; i < _listItems.Count; i++)
                {
                    tocInfo = _listItems[i][itemName];
                    if (tocInfo != null)
                    {
                        break;
                    }
                }
                if (tocInfo != null)
                {
                    return(tocInfo);
                }
                for (int i = 0; i < _listItems.Count; i++)
                {
                    tocInfo = _listItems[i].Find(itemName, true);
                    if (tocInfo != null)
                    {
                        break;
                    }
                }

                return(tocInfo);
            }
        }
Exemplo n.º 11
0
        public void Remove(BuildTopicTocInfo item)
        {
            if (item == null)
            {
                return;
            }
            if (_listTopics == null || _listTopics.Count == 0)
            {
                return;
            }

            if (!_listTopics.Remove(item))
            {
                BuildTopicTocInfo parent = item.Parent;
                if (parent != null)
                {
                    parent.Remove(item);
                }
            }
        }
Exemplo n.º 12
0
        public void Replace(BuildTopicTocInfo itemOut, BuildTopicTocInfo itemIn)
        {
            if (itemIn == null || itemOut == null || _listTopics == null)
            {
                return;
            }

            int index = this.IndexOf(itemOut);

            if (index < 0)
            {
                BuildTopicTocInfo itemParent = itemOut.Parent;
                if (itemParent != null)
                {
                    itemParent.Replace(itemOut, itemIn);
                }
                return;
            }

            _listTopics.RemoveAt(index);
            _listTopics.Insert(index, itemIn);
        }
Exemplo n.º 13
0
        public void Replace(BuildTopicTocInfo itemOut, BuildGroupTocInfo groupTocInfo)
        {
            if (itemOut == null || groupTocInfo == null || groupTocInfo.Count == 0 ||
                _listTopics == null)
            {
                return;
            }

            int index = this.IndexOf(itemOut);

            if (index < 0)
            {
                BuildTopicTocInfo itemParent = itemOut.Parent;
                if (itemParent != null)
                {
                    itemParent.Replace(itemOut, groupTocInfo);
                }
                return;
            }

            _listTopics.RemoveAt(index);
            _listTopics.Insert(index, groupTocInfo.Items);
        }
Exemplo n.º 14
0
 public bool Remove(BuildTopicTocInfo item)
 {
     return(_relatedTopics.Remove(item));
 }
Exemplo n.º 15
0
 public virtual int IndexOf(BuildTopicTocInfo item)
 {
     return(-1);
 }
Exemplo n.º 16
0
 public virtual void Remove(BuildTopicTocInfo item)
 {
 }
Exemplo n.º 17
0
 public virtual void Replace(BuildTopicTocInfo itemOut,
                             BuildGroupTocInfo groupTocInfo)
 {
 }
Exemplo n.º 18
0
 public virtual void Replace(BuildTopicTocInfo itemOut,
                             IList <BuildTopicTocInfo> items)
 {
 }
Exemplo n.º 19
0
 public virtual void Replace(BuildTopicTocInfo itemOut, BuildTopicTocInfo itemIn)
 {
 }
Exemplo n.º 20
0
 public virtual void Insert(int index, BuildTopicTocInfo item)
 {
 }
Exemplo n.º 21
0
 public virtual void Add(BuildTopicTocInfo item)
 {
 }
Exemplo n.º 22
0
        /// <summary>
        /// This reads and sets its state or attributes stored in a <c>XML</c> format
        /// with the given reader.
        /// </summary>
        /// <param name="reader">
        /// The reader with which the <c>XML</c> attributes of this object are accessed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>
        public override void ReadXml(XmlReader reader)
        {
            BuildExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);

            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }
            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                Debug.Assert(false, String.Format(
                                 "The element name '{0}' does not match the expected '{1}'.",
                                 reader.Name, TagName));
                return;
            }

            string topicId   = reader.GetAttribute("id");
            string topicFile = reader.GetAttribute("file");

            if (!String.IsNullOrEmpty(topicId) &&
                !String.IsNullOrEmpty(topicFile))
            {
                this.Name  = topicId;
                _source    = topicFile;
                _container = reader.GetAttribute("project");
            }
            else
            {
                return;
            }

            if (reader.IsEmptyElement)
            {
                return;
            }

            XmlNodeType nodeType = XmlNodeType.None;

            while (reader.Read())
            {
                nodeType = reader.NodeType;
                if (nodeType == XmlNodeType.Element && String.Equals(reader.Name, "topic",
                                                                     StringComparison.OrdinalIgnoreCase))
                {
                    BuildTopicTocInfo topic = new BuildTopicTocInfo(
                        Guid.NewGuid().ToString(), String.Empty, this);

                    topic.ReadXml(reader);

                    this.Add(topic);
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, BuildTopicTocInfo.TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }