示例#1
0
        ///<summary>
        ///  Забирает из ответа сервера данные по одному выходу и
        /// распределяет их по свойствам экземпляра
        /// Обработанные данные удаляются из ответа
        ///</summary>
        public void Update(MpdResponseCollection response)
        {
            if (response == null)
            {
                throw new BalboaNullValueException(_modName, "Update", "40", "responce");
            }

            int i = 0;

            do
            {
                string[] items    = response[i].Split(':');
                string   tagname  = items[0].ToLower();
                string   tagvalue = items[1].Trim();
                switch (tagname)
                {
                case "outputid":
                    Id = int.Parse(tagvalue, NumberStyles.Integer, CultureInfo.InvariantCulture);
                    break;

                case "outputname":
                    Name = tagvalue;
                    break;

                case "outputenabled": Enabled = (tagvalue == "1") ? true : false; break;
                }
                i++;
            }while ((i < response.Count) && (!response[i].StartsWith("outputid", StringComparison.OrdinalIgnoreCase)));
            response.RemoveRange(0, i);
        }
示例#2
0
        public void Update(MpdResponseCollection response)
        {
            int i = 0;

            if (response == null)
            {
                return;
            }
            do
            {
                string[] items    = response[i].Split(':');
                string   tagname  = items[0].ToLower();
                string   tagvalue = items[1].Trim();

                switch (tagname)
                {
                case "file":
                    Name   = Utilities.ExtractFileName(tagvalue, false);
                    Nature = FileNature.File;
                    Icon  += '\xE189';
                    break;              // 57737     // E189

                case "directory":
                    Name   = Utilities.ExtractFileName(tagvalue, false);
                    Nature = FileNature.Directory;
                    Icon  += '\xE188';
                    break;     // 57736    // E188

                case "playlist": Name = tagvalue; Nature = FileNature.Playlist; break;

                case "Last-Modified": LastModified = tagvalue; break;
                }
                i++;
            }while ((i < response.Count) && (!response[i].StartsWith("file", StringComparison.OrdinalIgnoreCase)) &&
                    (!response[i].StartsWith("playlist", StringComparison.OrdinalIgnoreCase)) &&
                    (!response[i].StartsWith("directory", StringComparison.OrdinalIgnoreCase)));
            response.RemoveRange(0, i);
        }
示例#3
0
        public void Update(MpdResponseCollection response)
        {
//            response = null;
            if (response == null)
            {
                throw new BalboaNullValueException(_modName, "Update", "95", "response");
            }

            int i = 0;

            do
            {
                string[] items    = response[i].Split(':');
                string   tagname  = items[0].ToLower();
                string   tagvalue = items[1].Trim();
                switch (tagname)
                {
                case "file": File = tagvalue; break;

                case "last-modified": LastModified = tagvalue; break;

                case "time": Time = float.Parse(tagvalue, NumberStyles.Float, CultureInfo.InvariantCulture); break;

                case "artist": Artist = tagvalue; break;

                case "title": Title = tagvalue; break;

                case "album": Album = tagvalue; break;

                case "date": Date = tagvalue; break;

                case "track": TrackNo = tagvalue; break;

                case "genre": Genre = tagvalue; break;

                case "composer": Composer = tagvalue; break;

                case "albumartist": AlbumArtist = tagvalue; break;

                case "disc": Disc = tagvalue; break;

                case "pos": Position = tagvalue; break;

                case "id": Id = int.Parse(tagvalue, NumberStyles.Integer, CultureInfo.InvariantCulture); break;

                // Database properties
                case "artistsort": ArtistSort = tagvalue; break;                                // same as artist, but for sorting.This usually omits prefixes such as "The".

                case "albumsort": AlbumSort = tagvalue; break;                                  // same as album, but for sorting.

                case "albumartistsort": AlbumArtistSort = tagvalue; break;                      // same as albumartist, but for sorting.

                case "name": Name = tagvalue; break;                                            // a name for this song.This is not the song title. The exact meaning of this tag is not well-defined.It is often used by badly configured internet radio stations with broken tags to squeeze both the artist name and the song title in one tag.

                case "performer": Performer = tagvalue; break;                                  // the artist who performed the song.

                case "comment": Comment = tagvalue; break;                                      // a human-readable comment about this song.The exact meaning of this tag is not well-defined.

                case "musicbrainz_artistid": MusicBrainzArtistId = tagvalue; break;             //  the artist id in the MusicBrainz database.

                case "musicbrainz_albumid": MusicBrainzAlbumId = tagvalue; break;               //  the album id in the MusicBrainz database.

                case "musicbrainz_albumartistid": MusicBrainzAlbumArtistId = tagvalue; break;   //  the album artist id in the MusicBrainz database.

                case "musicbrainz_trackid": MusicBrainzTrackId = tagvalue; break;               //  the track id in the MusicBrainz database.

                case "musicbrainz_releasetrackid": MusicBrainzReleaseTrackId = tagvalue; break; //  the release track id in the MusicBrainz database.
                }
                // Заполним пустые параметры значениями по умолчанию
                if (Title == null)
                {
                    Title = Utilities.ExtractFileName(File ?? "", true);
                }
                if (Artist == null)
                {
                    Artist = " Unknown artist";
                }
                if (Album == null)
                {
                    Album = " Unknown album";
                }
                if (Date == null)
                {
                    Date = " Unknown year";
                }
                i++;
            }while ((i < response.Count) && (!response[i].StartsWith("file", System.StringComparison.Ordinal)));

            response.RemoveRange(0, i);
        }