void IXmlSerializable.ReadXml(XmlReader reader)
 {
     try
     {
         // First read attributes, then check for empty start element
         if (!reader.MoveToAttribute("Role"))
         {
             throw new ArgumentException("Role attribute not present");
         }
         _role = new Guid(reader.Value);
         if (!reader.MoveToAttribute("LinkedRole"))
         {
             throw new ArgumentException("LinkedRole attribute not present");
         }
         _linkedRole = new Guid(reader.Value);
         if (reader.IsEmptyElement)
         {
             return;
         }
     }
     finally
     {
         reader.ReadStartElement();
     }
     while (reader.NodeType != XmlNodeType.EndElement)
     {
         if (reader.Name == "Aspect")
         {
             MediaItemAspect mia = MediaItemAspect.Deserialize(reader);
             if (mia is SingleMediaItemAspect)
             {
                 MediaItemAspect.SetAspect(_aspects, (SingleMediaItemAspect)mia);
             }
             else if (mia is MultipleMediaItemAspect)
             {
                 MediaItemAspect.AddOrUpdateAspect(_aspects, (MultipleMediaItemAspect)mia);
             }
         }
         else
         {
             reader.Read();
         }
     }
     reader.ReadEndElement(); // RI
 }
示例#2
0
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            try
            {
                // First read attributes, then check for empty start element
                if (!reader.MoveToAttribute("Id"))
                {
                    throw new ArgumentException("Id attribute not present");
                }
                _id = new Guid(reader.Value);
                if (reader.IsEmptyElement)
                {
                    return;
                }
            }
            finally
            {
                reader.ReadStartElement();
            }
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.Name == "Aspect")
                {
                    MediaItemAspect mia = MediaItemAspect.Deserialize(reader);
                    if (mia is SingleMediaItemAspect)
                    {
                        MediaItemAspect.SetAspect(_aspects, (SingleMediaItemAspect)mia);
                    }
                    else if (mia is MultipleMediaItemAspect)
                    {
                        MediaItemAspect.AddOrUpdateAspect(_aspects, (MultipleMediaItemAspect)mia);
                    }
                }
                else if (reader.Name == "UserData")
                {
                    string key  = null;
                    string data = null;

                    if (reader.MoveToAttribute("Key"))
                    {
                        key = reader.ReadContentAsString();
                    }
                    if (reader.MoveToAttribute("Data"))
                    {
                        data = reader.ReadContentAsString();
                    }

                    if (key != null && data != null)
                    {
                        _userData.Add(key, data);
                    }

                    reader.Read();
                }
                else
                {
                    reader.Read();
                }
            }
            reader.ReadEndElement(); // MI
        }