/// <summary>Deserializes the <see cref="T:System.Windows.Annotations.ContentLocatorGroup" /> from a specified <see cref="T:System.Xml.XmlReader" />.</summary>
 /// <param name="reader">The XML reader to use to deserialize the <see cref="T:System.Windows.Annotations.ContentLocatorGroup" />.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="reader" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.Xml.XmlException">The serialized XML for the <see cref="T:System.Windows.Annotations.ContentLocatorGroup" /> is not valid.</exception>
 // Token: 0x06006345 RID: 25413 RVA: 0x001BECA4 File Offset: 0x001BCEA4
 public void ReadXml(XmlReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     Annotation.CheckForNonNamespaceAttribute(reader, "ContentLocatorGroup");
     if (!reader.IsEmptyElement)
     {
         reader.Read();
         while (!("ContentLocatorGroup" == reader.LocalName) || XmlNodeType.EndElement != reader.NodeType)
         {
             if (!("ContentLocator" == reader.LocalName))
             {
                 throw new XmlException(SR.Get("InvalidXmlContent", new object[]
                 {
                     "ContentLocatorGroup"
                 }));
             }
             ContentLocator item = (ContentLocator)AnnotationResource.ListSerializer.Deserialize(reader);
             this._locators.Add(item);
         }
     }
     reader.Read();
 }
Exemplo n.º 2
0
        /// <summary>
        ///     Reads the internal data for this ContentLocatorGroup from the reader.  This method
        ///     is used by an XmlSerializer to deserialize a ContentLocatorGroup.  To deserialize a
        ///     ContentLocatorGroup from Xml, use an XmlSerializer.
        /// </summary>
        /// <param name="reader">the reader to read internal data from</param>
        /// <exception cref="ArgumentNullException">reader is null</exception>
        public void ReadXml(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            // We expect no attributes on a "ContentLocatorGroup",
            // so throw using the name of one of the unexpected attributes
            Annotation.CheckForNonNamespaceAttribute(reader, AnnotationXmlConstants.Elements.ContentLocatorGroup);

            if (!reader.IsEmptyElement)
            {
                reader.Read();  // Reads the start of the "ContentLocatorGroup" element

                // Consume everything inside of the ContentLocatorGroup tag.
                while (!(AnnotationXmlConstants.Elements.ContentLocatorGroup == reader.LocalName && XmlNodeType.EndElement == reader.NodeType))
                {
                    // If a child node is a <ContentLocatorBase>, deserialize a ContentLocatorBase
                    if (AnnotationXmlConstants.Elements.ContentLocator == reader.LocalName)
                    {
                        ContentLocator locator = (ContentLocator)AnnotationResource.ListSerializer.Deserialize(reader);
                        _locators.Add(locator);
                    }
                    else
                    {
                        // The ContentLocatorGroup contains a child that is not a ContentLocatorBase or
                        // text.  This isn't valid in the schema so we throw.
                        throw new XmlException(SR.Get(SRID.InvalidXmlContent, AnnotationXmlConstants.Elements.ContentLocatorGroup));
                    }
                }
            }

            reader.Read();   // Reads the end of the "ContentLocatorGroup" element (or whole element if empty)
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Reads the internal data for this ContentLocator from the reader.  This
        ///     method is used by an XmlSerializer to deserialize a ContentLocator.  Don't
        ///     use this method directly, to deserialize a ContentLocator from Xml, use an
        ///     XmlSerializer.
        /// </summary>
        /// <param name="reader">the reader to read internal data from</param>
        /// <exception cref="ArgumentNullException">reader is null</exception>
        public void ReadXml(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            // We expect no attributes on a "ContentLocator",
            // so throw using the name of one of the unexpected attributes
            Annotation.CheckForNonNamespaceAttribute(reader, AnnotationXmlConstants.Elements.ContentLocator);

            if (!reader.IsEmptyElement)
            {
                reader.Read();  // Reads the start of the "ContentLocator" element

                // ContentLocatorParts cannot write themselves out (see above).  They could read
                // themselves in but instead of having write code in one place and read
                // code somewhere else - we keep it together in this class.
                while (!(AnnotationXmlConstants.Elements.ContentLocator == reader.LocalName && XmlNodeType.EndElement == reader.NodeType))
                {
                    if (XmlNodeType.Element != reader.NodeType)
                    {
                        throw new XmlException(SR.Get(SRID.InvalidXmlContent, AnnotationXmlConstants.Elements.ContentLocator));
                    }

                    ContentLocatorPart part = new ContentLocatorPart(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI));

                    // Read each of the Item elements within the ContentLocatorPart
                    if (!reader.IsEmptyElement)
                    {
                        // We expect no attributes on a locator part tag,
                        // so throw using the name of one of the unexpected attributes
                        Annotation.CheckForNonNamespaceAttribute(reader, part.PartType.Name);

                        reader.Read(); // Read the start of the locator part tag

                        while (!(XmlNodeType.EndElement == reader.NodeType && part.PartType.Name == reader.LocalName))
                        {
                            if (AnnotationXmlConstants.Elements.Item == reader.LocalName && reader.NamespaceURI == AnnotationXmlConstants.Namespaces.CoreSchemaNamespace)
                            {
                                string name  = null;
                                string value = null;

                                while (reader.MoveToNextAttribute())
                                {
                                    switch (reader.LocalName)
                                    {
                                    case AnnotationXmlConstants.Attributes.ItemName:
                                        name = reader.Value;
                                        break;

                                    case AnnotationXmlConstants.Attributes.ItemValue:
                                        value = reader.Value;
                                        break;

                                    default:
                                        if (!Annotation.IsNamespaceDeclaration(reader))
                                        {
                                            throw new XmlException(SR.Get(SRID.UnexpectedAttribute, reader.LocalName, AnnotationXmlConstants.Elements.Item));
                                        }
                                        break;
                                    }
                                }

                                if (name == null)
                                {
                                    throw new XmlException(SR.Get(SRID.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.ItemName, AnnotationXmlConstants.Elements.Item));
                                }
                                if (value == null)
                                {
                                    throw new XmlException(SR.Get(SRID.RequiredAttributeMissing, AnnotationXmlConstants.Attributes.ItemValue, AnnotationXmlConstants.Elements.Item));
                                }

                                reader.MoveToContent();

                                part.NameValuePairs.Add(name, value);

                                bool isEmpty = reader.IsEmptyElement;

                                reader.Read();  // Read the beginning of the complete Item tag

                                if (!isEmpty)
                                {
                                    if (!(XmlNodeType.EndElement == reader.NodeType && AnnotationXmlConstants.Elements.Item == reader.LocalName))
                                    {
                                        // Should not contain any content, only attributes
                                        throw new XmlException(SR.Get(SRID.InvalidXmlContent, AnnotationXmlConstants.Elements.Item));
                                    }
                                    else
                                    {
                                        reader.Read(); // Read the end of the Item tag
                                    }
                                }
                            }
                            else
                            {
                                // The locator part contains data other than just "Item" tags
                                throw new XmlException(SR.Get(SRID.InvalidXmlContent, part.PartType.Name));
                            }
                        }
                    }

                    _parts.Add(part);

                    reader.Read();  // Read the ContentLocatorPart element
                }
            }

            reader.Read(); // Reads the end of the "ContentLocator" element (or whole element if empty)
        }
 /// <summary>Deserializes the <see cref="T:System.Windows.Annotations.Annotation" /> from a specified <see cref="T:System.Xml.XmlReader" />. </summary>
 /// <param name="reader">The XML reader to use to deserialize the annotation.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="reader" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.Xml.XmlException">The serialized XML for the <see cref="T:System.Windows.Annotations.Annotation" /> is not valid.</exception>
 // Token: 0x06006264 RID: 25188 RVA: 0x001B9954 File Offset: 0x001B7B54
 public void ReadXml(XmlReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.DeserializeAnnotationBegin);
     try
     {
         XmlDocument xmlDocument = new XmlDocument();
         this.ReadAttributes(reader);
         if (!reader.IsEmptyElement)
         {
             reader.Read();
             while (XmlNodeType.EndElement != reader.NodeType || !("Annotation" == reader.LocalName))
             {
                 if ("Anchors" == reader.LocalName)
                 {
                     Annotation.CheckForNonNamespaceAttribute(reader, "Anchors");
                     if (!reader.IsEmptyElement)
                     {
                         reader.Read();
                         while (!("Anchors" == reader.LocalName) || XmlNodeType.EndElement != reader.NodeType)
                         {
                             AnnotationResource item = (AnnotationResource)Annotation.ResourceSerializer.Deserialize(reader);
                             this._anchors.Add(item);
                         }
                     }
                     reader.Read();
                 }
                 else if ("Cargos" == reader.LocalName)
                 {
                     Annotation.CheckForNonNamespaceAttribute(reader, "Cargos");
                     if (!reader.IsEmptyElement)
                     {
                         reader.Read();
                         while (!("Cargos" == reader.LocalName) || XmlNodeType.EndElement != reader.NodeType)
                         {
                             AnnotationResource item2 = (AnnotationResource)Annotation.ResourceSerializer.Deserialize(reader);
                             this._cargos.Add(item2);
                         }
                     }
                     reader.Read();
                 }
                 else
                 {
                     if (!("Authors" == reader.LocalName))
                     {
                         throw new XmlException(SR.Get("InvalidXmlContent", new object[]
                         {
                             "Annotation"
                         }));
                     }
                     Annotation.CheckForNonNamespaceAttribute(reader, "Authors");
                     if (!reader.IsEmptyElement)
                     {
                         reader.Read();
                         while (!("Authors" == reader.LocalName) || XmlNodeType.EndElement != reader.NodeType)
                         {
                             if (!("StringAuthor" == reader.LocalName) || XmlNodeType.Element != reader.NodeType)
                             {
                                 throw new XmlException(SR.Get("InvalidXmlContent", new object[]
                                 {
                                     "Annotation"
                                 }));
                             }
                             XmlNode xmlNode = xmlDocument.ReadNode(reader);
                             if (!reader.IsEmptyElement)
                             {
                                 this._authors.Add(xmlNode.InnerText);
                             }
                         }
                     }
                     reader.Read();
                 }
             }
         }
         reader.Read();
     }
     finally
     {
         EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.DeserializeAnnotationEnd);
     }
 }
Exemplo n.º 5
0
 /// <summary>Deserializes the <see cref="T:System.Windows.Annotations.ContentLocator" /> from a specified <see cref="T:System.Xml.XmlReader" />.</summary>
 /// <param name="reader">The XML reader to use to deserialize the <see cref="T:System.Windows.Annotations.ContentLocator" />.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///         <paramref name="reader" /> is <see langword="null" />.</exception>
 /// <exception cref="T:System.Xml.XmlException">The serialized XML for the <see cref="T:System.Windows.Annotations.ContentLocator" /> is not valid.</exception>
 // Token: 0x0600633B RID: 25403 RVA: 0x001BE740 File Offset: 0x001BC940
 public void ReadXml(XmlReader reader)
 {
     if (reader == null)
     {
         throw new ArgumentNullException("reader");
     }
     Annotation.CheckForNonNamespaceAttribute(reader, "ContentLocator");
     if (!reader.IsEmptyElement)
     {
         reader.Read();
         while (!("ContentLocator" == reader.LocalName) || XmlNodeType.EndElement != reader.NodeType)
         {
             if (XmlNodeType.Element != reader.NodeType)
             {
                 throw new XmlException(SR.Get("InvalidXmlContent", new object[]
                 {
                     "ContentLocator"
                 }));
             }
             ContentLocatorPart contentLocatorPart = new ContentLocatorPart(new XmlQualifiedName(reader.LocalName, reader.NamespaceURI));
             if (!reader.IsEmptyElement)
             {
                 Annotation.CheckForNonNamespaceAttribute(reader, contentLocatorPart.PartType.Name);
                 reader.Read();
                 while (XmlNodeType.EndElement != reader.NodeType || !(contentLocatorPart.PartType.Name == reader.LocalName))
                 {
                     if (!("Item" == reader.LocalName) || !(reader.NamespaceURI == "http://schemas.microsoft.com/windows/annotations/2003/11/core"))
                     {
                         throw new XmlException(SR.Get("InvalidXmlContent", new object[]
                         {
                             contentLocatorPart.PartType.Name
                         }));
                     }
                     string text  = null;
                     string text2 = null;
                     while (reader.MoveToNextAttribute())
                     {
                         string localName = reader.LocalName;
                         if (!(localName == "Name"))
                         {
                             if (!(localName == "Value"))
                             {
                                 if (!Annotation.IsNamespaceDeclaration(reader))
                                 {
                                     throw new XmlException(SR.Get("UnexpectedAttribute", new object[]
                                     {
                                         reader.LocalName,
                                         "Item"
                                     }));
                                 }
                             }
                             else
                             {
                                 text2 = reader.Value;
                             }
                         }
                         else
                         {
                             text = reader.Value;
                         }
                     }
                     if (text == null)
                     {
                         throw new XmlException(SR.Get("RequiredAttributeMissing", new object[]
                         {
                             "Name",
                             "Item"
                         }));
                     }
                     if (text2 == null)
                     {
                         throw new XmlException(SR.Get("RequiredAttributeMissing", new object[]
                         {
                             "Value",
                             "Item"
                         }));
                     }
                     reader.MoveToContent();
                     contentLocatorPart.NameValuePairs.Add(text, text2);
                     bool isEmptyElement = reader.IsEmptyElement;
                     reader.Read();
                     if (!isEmptyElement)
                     {
                         if (XmlNodeType.EndElement != reader.NodeType || !("Item" == reader.LocalName))
                         {
                             throw new XmlException(SR.Get("InvalidXmlContent", new object[]
                             {
                                 "Item"
                             }));
                         }
                         reader.Read();
                     }
                 }
             }
             this._parts.Add(contentLocatorPart);
             reader.Read();
         }
     }
     reader.Read();
 }