Ejemplo n.º 1
0
        /// <summary>
        /// Parses a personal event from its XML representation
        /// </summary>
        /// <param name="E">XML representation of personal event.</param>
        /// <returns>Personal event object.</returns>
        public override IPersonalEvent Parse(XmlElement E)
        {
            UserTune Result = new UserTune();

            foreach (XmlNode N in E.ChildNodes)
            {
                if (N is XmlElement E2)
                {
                    switch (E2.LocalName)
                    {
                    case "artist":
                        Result.artist = E2.InnerText;
                        break;

                    case "length":
                        if (ushort.TryParse(E2.InnerText, out ushort us))
                        {
                            Result.length = us;
                        }
                        break;

                    case "rating":
                        if (byte.TryParse(E2.InnerText, out byte b))
                        {
                            Result.rating = b;
                        }
                        break;

                    case "source":
                        Result.source = E2.InnerText;
                        break;

                    case "title":
                        Result.title = E2.InnerText;
                        break;

                    case "track":
                        Result.track = E2.InnerText;
                        break;

                    case "uri":
                        try
                        {
                            Result.uri = new Uri(E2.InnerText);
                        }
                        catch (Exception)
                        {
                            // Ignore.
                        }
                        break;
                    }
                }
            }

            return(Result);
        }
Ejemplo n.º 2
0
 internal UserTuneEventArguments(UserTune Tune, PersonalEventNotificationEventArgs e) :
     base(e)
 {
     this.tune = Tune;
 }