Exemplo n.º 1
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;
            }

            if (reader.IsEmptyElement)
            {
                return;
            }

            if (_listSources == null)
            {
                _listSources = new BuildKeyedList <ReferenceVersionSource>();
            }
            if (_listRelated == null)
            {
                _listRelated = new BuildKeyedList <ReferenceVersionRelated>();
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, "propertyGroup",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                            {
                                if (String.Equals(reader.Name, "property",
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    string tempText = null;
                                    switch (reader.GetAttribute("name").ToLower())
                                    {
                                    case "platformid":
                                        _platformId = reader.ReadString();
                                        break;

                                    case "platformtitle":
                                        _platformTitle = reader.ReadString();
                                        break;

                                    case "platformfilters":
                                        tempText = reader.ReadString();
                                        if (!String.IsNullOrEmpty(tempText))
                                        {
                                            _platformFilters = Convert.ToBoolean(tempText);
                                        }
                                        break;

                                    case "versionid":
                                        _versionId = reader.ReadString();
                                        break;

                                    case "versionlabel":
                                        _versionLabel = reader.ReadString();
                                        break;

                                    case "ripoldapis":
                                        tempText = reader.ReadString();
                                        if (!String.IsNullOrEmpty(tempText))
                                        {
                                            _ripOldApis = Convert.ToBoolean(tempText);
                                        }
                                        break;

                                    default:
                                        // Should normally not reach here...
                                        throw new NotImplementedException(reader.GetAttribute("name"));
                                    }
                                }
                            }
                            else if (reader.NodeType == XmlNodeType.EndElement)
                            {
                                if (String.Equals(reader.Name, "propertyGroup",
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else if (String.Equals(reader.Name, ReferenceSource.TagName,
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        ReferenceVersionSource versionSource =
                            new ReferenceVersionSource();

                        versionSource.ReadXml(reader);

                        _listSources.Add(versionSource);
                    }
                    else if (String.Equals(reader.Name, ReferenceVersionRelated.TagName,
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        ReferenceVersionRelated relatedVersion =
                            new ReferenceVersionRelated();

                        relatedVersion.ReadXml(reader);

                        _listRelated.Add(relatedVersion);
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
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;
            }

            if (reader.IsEmptyElement)
            {
                return;
            }

            if (_listSources == null)
            {
                _listSources = new BuildKeyedList <ReferenceVersionSource>();
            }

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (String.Equals(reader.Name, "propertyGroup",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element)
                            {
                                if (String.Equals(reader.Name, "property",
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    switch (reader.GetAttribute("name").ToLower())
                                    {
                                    case "platformid":
                                        _platformId = reader.ReadString();
                                        break;

                                    case "platformtitle":
                                        _platformTitle = reader.ReadString();
                                        break;

                                    default:
                                        // Should normally not reach here...
                                        throw new NotImplementedException(reader.GetAttribute("name"));
                                    }
                                }
                            }
                            else if (reader.NodeType == XmlNodeType.EndElement)
                            {
                                if (String.Equals(reader.Name, "propertyGroup",
                                                  StringComparison.OrdinalIgnoreCase))
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else if (String.Equals(reader.Name, ReferenceSource.TagName,
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        string sourceName = reader.GetAttribute("name");
                        if (String.Equals(sourceName, ReferenceVersionSource.SourceName,
                                          StringComparison.OrdinalIgnoreCase))
                        {
                            ReferenceVersionSource source = new ReferenceVersionSource();

                            source.ReadXml(reader);

                            _listSources.Add(source);
                        }
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, TagName,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }