示例#1
0
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            //if (this.IsEmpty)
            //{
            //    return;
            //}

            writer.WriteStartElement(this.XmlTagName);  // start - reference

            foreach (KeyValuePair <string, string> item in _properties)
            {
                writer.WriteAttributeString(item.Key, item.Value);
            }

            if (base.IsEmpty)
            {
                writer.WriteEndElement();               // end - reference
            }
            else
            {
                for (int i = 0; i < this.Count; i++)
                {
                    this[i].WriteXml(writer);
                }

                writer.WriteFullEndElement();           // end - reference
            }
        }
        public void InsertAfterChild(VcProjectElement element,
                                     VcProjectElement reference)
        {
            ProjectExceptions.NotNull(element, "element");
            if (reference == null)
            {
                this.PrependChild(element);
                return;
            }

            if (element.Parent != this || reference.Parent != this)
            {
                throw new InvalidOperationException(
                          "The element is not created by this container.");
            }

            if (_children.Count != 0 && _children.Contains(element))
            {
                return;
            }

            int index = _children.IndexOf(reference);

            if (index < 0)
            {
                throw new InvalidOperationException(
                          "The referenced child is not found.");
            }

            _children.Insert(index + 1, element);
        }
示例#3
0
        public override void ReadXml(XmlReader reader)
        {
            ProjectExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            // Keep this, after reading the attributes, the reader will be
            // on the last attribute, and this property will return false...
            bool isEmptyElement = reader.IsEmptyElement;

            while (reader.MoveToNextAttribute())
            {
                _properties.Add(reader.Name, reader.Value);
            }

            if (isEmptyElement)
            {
                return;
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (this.IsChildElement(reader.Name))
                    {
                        VcProjectElement element = this.CreateChildElement(reader.Name);
                        element.ReadXml(reader);

                        this.AppendChild(element);
                    }
                    else
                    {
                        throw new InvalidOperationException(String.Format(
                                                                "The element '{0}' is not a child element of {1}", reader.Name,
                                                                TagName));
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
示例#4
0
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            if (!String.IsNullOrEmpty(_comment))
            {
                writer.WriteComment(_comment);
            }
        }
        public int IndexOfChild(VcProjectElement element)
        {
            ProjectExceptions.NotNull(element, "element");

            if (_children.Count == 0)
            {
                return(-1);
            }

            return(_children.IndexOf(element));
        }
        public bool RemoveChild(VcProjectElement element)
        {
            ProjectExceptions.NotNull(element, "element");

            if (_children.Count == 0)
            {
                return(false);
            }

            return(_children.Remove(element));
        }
示例#7
0
        public override void ReadXml(XmlReader reader)
        {
            ProjectExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Comment);
            if (reader.NodeType != XmlNodeType.Comment)
            {
                return;
            }

            _comment = reader.Value;
        }
示例#8
0
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            if (this.IsEmpty)
            {
                return;
            }

            writer.WriteStartElement(TagName);  // start - Platform
            writer.WriteAttributeString("Name", _name);
            writer.WriteEndElement();           // end - Platform
        }
示例#9
0
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            if (this.IsEmpty)
            {
                return;
            }

            writer.WriteStartElement(TagName);  // start - DefaultToolFile
            writer.WriteAttributeString("FileName", _fileName);
            writer.WriteEndElement();           // end - DefaultToolFile
        }
示例#10
0
        /// <summary>
        /// This writes the current state or attributes of this object,
        /// in the <c>XML</c> format, to the media or storage accessible by the given writer.
        /// </summary>
        /// <param name="writer">
        /// The <c>XML</c> writer with which the <c>XML</c> format of this object's state
        /// is written.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="reader"/> is <see langword="null"/>.
        /// </exception>
        public void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            writer.WriteStartElement(TagName);  // start - properties

            foreach (KeyValuePair <string, string> item in _dictionary)
            {
                writer.WriteStartElement(ItemTagName); // start - property
                writer.WriteAttributeString("name", item.Key);
                writer.WriteString(item.Value);
                writer.WriteEndElement();              // end - property
            }

            writer.WriteEndElement();           // end - properties
        }
        public bool ContainsChild(VcProjectElement element)
        {
            ProjectExceptions.NotNull(element, "element");

            if (element.Parent == null || element.Parent != this ||
                _children.Count == 0)
            {
                return(false);
            }

            if (element.Parent == this)
            {
                return(true);
            }
            return(_children.Contains(element));
        }
        public void InsertChild(int index, VcProjectElement element)
        {
            ProjectExceptions.NotNull(element, "element");

            if (element.Parent != this)
            {
                throw new InvalidOperationException(
                          "The element is not created by this container.");
            }

            if (_children.Count != 0 && _children.Contains(element))
            {
                return;
            }
            _children.Insert(index, element);
        }
        public override void ReadXml(XmlReader reader)
        {
            ProjectExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            string tagName = this.XmlTagName;

            if (!String.Equals(reader.Name, tagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (this.IsChildElement(reader.Name))
                    {
                        VcProjectElement element = this.CreateChildElement(reader.Name);
                        element.ReadXml(reader);

                        this.AppendChild(element);
                    }
                    else
                    {
                        throw new InvalidOperationException(String.Format(
                                                                "The element '{0}' is not a child element of {1}", reader.Name,
                                                                tagName));
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, tagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
示例#14
0
        public override void ReadXml(XmlReader reader)
        {
            ProjectExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            _fileName = reader.GetAttribute("FileName");
        }
示例#15
0
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            writer.WriteStartElement(TagName);  // start - VisualStudioProject

            foreach (KeyValuePair <string, string> item in _properties)
            {
                writer.WriteAttributeString(item.Key, item.Value);
            }

            for (int i = 0; i < this.Count; i++)
            {
                this[i].WriteXml(writer);
            }

            writer.WriteFullEndElement();       // end - VisualStudioProject
        }
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            //if (this.IsEmpty)
            //{
            //    return;
            //}

            writer.WriteStartElement(this.XmlTagName);  // start - the collection

            for (int i = 0; i < this.Count; i++)
            {
                this[i].WriteXml(writer);
            }

            writer.WriteFullEndElement();                   // end - the collection
        }
示例#17
0
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            if (this.IsEmpty)
            {
                return;
            }

            writer.WriteStartElement(TagName);  // start - Tool

            foreach (KeyValuePair <string, string> item in _properties)
            {
                writer.WriteAttributeString(item.Key, item.Value);
            }

            writer.WriteEndElement();           // end - Tool
        }
示例#18
0
        public override void ReadXml(XmlReader reader)
        {
            ProjectExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            while (reader.MoveToNextAttribute())
            {
                _properties.Add(reader.Name, reader.Value);
            }
        }
示例#19
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 void ReadXml(XmlReader reader)
        {
            ProjectExceptions.NotNull(reader, "reader");

            Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (reader.NodeType != XmlNodeType.Element)
            {
                return;
            }

            if (!String.Equals(reader.Name, TagName,
                               StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, ItemTagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        string name  = reader.GetAttribute("name");
                        string value = reader.ReadString();

                        this.Add(name, value);
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
        public override void WriteXml(XmlWriter writer)
        {
            ProjectExceptions.NotNull(writer, "writer");

            //if (this.IsEmpty)
            //{
            //    return;
            //}

            writer.WriteStartElement(_tagName);  // start - configuration

            foreach (KeyValuePair <string, string> item in _properties)
            {
                writer.WriteAttributeString(item.Key, item.Value);
            }

            for (int i = 0; i < this.Count; i++)
            {
                this[i].WriteXml(writer);
            }

            writer.WriteEndElement();            // end - the configuration
        }