Exemplo n.º 1
0
        // Creates an TrackData object from an XElement, assumes that the XElement
        // passed is the portion of XML referring to a track entry including
        // and containing the element <dict>
        public TrackInfo(XElement element)
        {
            // This value should always be present, so it is safe to convert without checking
            trackId = Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TRACK_ID));

            trackTitle  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_NAME);
            artist      = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_ARTIST);
            albumArtist = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_ALBUM_ARTIST);
            album       = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_ALBUM);
            genre       = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_GENRE);
            kind        = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_KIND);
            trackNumber = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TRACK_NUMBER);
            trackCount  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TRACK_COUNT);
            discNumber  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_DISC_NUMBER);
            discCount   = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_DISC_COUNT);
            year        = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_YEAR);
            comments    = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_COMMENTS);
            compilation = PlistHelper.IsKeyInDict(element, Consts.PLIST_KEY_COMPILATION);

            dateAdded  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_DATE_ADDED);
            lastPlayed = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_LAST_PLAYED);
            playCount  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_PLAY_COUNT);
            rating     = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_RATING);

            totalTime = Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TOTAL_TIME));
            fileSize  = Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_SIZE));
            location  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_LOCATION);
            location  = Uri.UnescapeDataString(location);
            fileName  = System.IO.Path.GetFileName(location);
        }