コード例 #1
0
        /// <summary>
        /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
        /// to read the contents of the <see cref="Slideshow"/> that
        /// are exposed in this override. It deserializes recursively.
        /// </summary>
        /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
        /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
        public override void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
        {
            var shuffleSerializer = new XmlSerializer(typeof(CustomShuffling));

            // Check for Versions < Ogama 4.3
            if (reader.Name == "SlideshowTreeNode")
            {
                base.DeserializeNode(reader, node);
                return;
            }

            reader.ReadStartElement("IsModified");
            this.IsModified = reader.ReadContentAsBoolean();
            reader.ReadEndElement();

            if (reader.Name == "CustomShuffling")
            {
                this.shuffling = (CustomShuffling)shuffleSerializer.Deserialize(reader);
            }


            while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
                   (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
            {
                if (reader.Name == "SlideshowTreeNode")
                {
                    var newNode = new SlideshowTreeNode();
                    newNode.DeserializeNode(reader, newNode);
                    this.SetTreeNodeImageKey(newNode);
                    node.Nodes.Add(newNode);
                }
                else if (reader.Name == "BrowserTreeNode")
                {
                    var newNode = new BrowserTreeNode();
                    newNode.DeserializeNode(reader, newNode);
                    this.SetTreeNodeImageKey(newNode);
                    node.Nodes.Add(newNode);
                }
            }
        }
コード例 #2
0
ファイル: Slideshow.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
    /// to read the contents of the <see cref="Slideshow"/> that 
    /// are exposed in this override. It deserializes recursively.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
    /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
    public override void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
    {
      var shuffleSerializer = new XmlSerializer(typeof(CustomShuffling));

      // Check for Versions < Ogama 4.3
      if (reader.Name == "SlideshowTreeNode")
      {
        base.DeserializeNode(reader, node);
        return;
      }

      reader.ReadStartElement("IsModified");
      this.IsModified = reader.ReadContentAsBoolean();
      reader.ReadEndElement();

      if (reader.Name == "CustomShuffling")
      {
        this.shuffling = (CustomShuffling)shuffleSerializer.Deserialize(reader);
      }


      while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
        (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
      {
        if (reader.Name == "SlideshowTreeNode")
        {
          var newNode = new SlideshowTreeNode();
          newNode.DeserializeNode(reader, newNode);
          this.SetTreeNodeImageKey(newNode);
          node.Nodes.Add(newNode);
        }
        else if (reader.Name == "BrowserTreeNode")
        {
          var newNode = new BrowserTreeNode();
          newNode.DeserializeNode(reader, newNode);
          this.SetTreeNodeImageKey(newNode);
          node.Nodes.Add(newNode);
        }
      }
    }
コード例 #3
0
        /// <summary>
        /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
        /// to read the contents of the <see cref="SlideshowTreeNode"/> that
        /// are exposed in this override.
        /// It deserializes recursively.
        /// </summary>
        /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
        /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
        public virtual void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
        {
            var slideSerializer = new XmlSerializer(typeof(Slide));

            // Check for older versions of Ogama 1.X
            if (reader.Name == "Slides")
            {
                // A List<Slide> instead of SlideshowTreeNodes
                // in the slideshow node
                reader.ReadStartElement("Slides");
                this.ParseOgamaV1Slideshow(reader, slideSerializer);
                reader.ReadEndElement();
            }
            else if (reader.Name == "Slide")
            {
                // Directly the slides in the slideshow node
                this.ParseOgamaV1Slideshow(reader, slideSerializer);
            }
            else
            {
                // Ogama V2 format
                reader.ReadStartElement("SlideshowTreeNode");
                reader.ReadStartElement("Name");
                node.Name = reader.ReadString();
                reader.ReadEndElement();
                reader.ReadStartElement("Randomize");
                node.Randomize = reader.ReadContentAsBoolean();
                reader.ReadEndElement();
                reader.ReadStartElement("NumberOfItemsToUse");
                node.NumberOfItemsToUse = reader.ReadContentAsInt();
                reader.ReadEndElement();

                if (reader.Name == "Slide")
                {
                    node.Slide = (Slide)slideSerializer.Deserialize(reader);
                }

                reader.ReadStartElement("Tag");
                if (reader.Value != string.Empty)
                {
                    node.Tag = reader.ReadContentAsString();
                    reader.ReadEndElement();
                }

                reader.ReadStartElement("Text");
                node.Text = reader.ReadContentAsString();
                reader.ReadEndElement();
                while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
                       (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
                {
                    if (reader.Name == "SlideshowTreeNode")
                    {
                        var newNode = new SlideshowTreeNode();
                        newNode.DeserializeNode(reader, newNode);
                        this.SetTreeNodeImageKey(newNode);
                        node.Nodes.Add(newNode);
                    }
                    else if (reader.Name == "BrowserTreeNode")
                    {
                        var newNode = new BrowserTreeNode();
                        newNode.DeserializeNode(reader, newNode);
                        this.SetTreeNodeImageKey(newNode);
                        node.Nodes.Add(newNode);
                    }
                }

                reader.ReadEndElement();

                reader.MoveToContent();
            }
        }
コード例 #4
0
ファイル: SlideshowTreeNode.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// This method is a custom deserialization with an <see cref="XmlSerializer"/>
    /// to read the contents of the <see cref="SlideshowTreeNode"/> that 
    /// are exposed in this override.
    /// It deserializes recursively.
    /// </summary>
    /// <param name="reader">The <see cref="XmlReader"/> to use.</param>
    /// <param name="node">The <see cref="SlideshowTreeNode"/> to deserialize.</param>
    public virtual void DeserializeNode(XmlReader reader, SlideshowTreeNode node)
    {
      var slideSerializer = new XmlSerializer(typeof(Slide));

      // Check for older versions of Ogama 1.X 
      if (reader.Name == "Slides")
      {
        // A List<Slide> instead of SlideshowTreeNodes
        // in the slideshow node
        reader.ReadStartElement("Slides");
        this.ParseOgamaV1Slideshow(reader, slideSerializer);
        reader.ReadEndElement();
      }
      else if (reader.Name == "Slide")
      {
        // Directly the slides in the slideshow node
        this.ParseOgamaV1Slideshow(reader, slideSerializer);
      }
      else
      {
        // Ogama V2 format
        reader.ReadStartElement("SlideshowTreeNode");
        reader.ReadStartElement("Name");
        node.Name = reader.ReadString();
        reader.ReadEndElement();
        reader.ReadStartElement("Randomize");
        node.Randomize = reader.ReadContentAsBoolean();
        reader.ReadEndElement();
        reader.ReadStartElement("NumberOfItemsToUse");
        node.NumberOfItemsToUse = reader.ReadContentAsInt();
        reader.ReadEndElement();

        if (reader.Name == "Slide")
        {
          node.Slide = (Slide)slideSerializer.Deserialize(reader);
        }

        reader.ReadStartElement("Tag");
        if (reader.Value != string.Empty)
        {
          node.Tag = reader.ReadContentAsString();
          reader.ReadEndElement();
        }

        reader.ReadStartElement("Text");
        node.Text = reader.ReadContentAsString();
        reader.ReadEndElement();
        while ((reader.Name == "SlideshowTreeNode" && reader.NodeType == XmlNodeType.Element) ||
          (reader.Name == "BrowserTreeNode" && reader.NodeType == XmlNodeType.Element))
        {
          if (reader.Name == "SlideshowTreeNode")
          {
            var newNode = new SlideshowTreeNode();
            newNode.DeserializeNode(reader, newNode);
            this.SetTreeNodeImageKey(newNode);
            node.Nodes.Add(newNode);
          }
          else if (reader.Name == "BrowserTreeNode")
          {
            var newNode = new BrowserTreeNode();
            newNode.DeserializeNode(reader, newNode);
            this.SetTreeNodeImageKey(newNode);
            node.Nodes.Add(newNode);
          }
        }

        reader.ReadEndElement();

        reader.MoveToContent();
      }
    }