Libmpc.Mpc.Stats C# (CSharp) Method

Stats() public method

Requests the current statistics from the MPD,
public Stats ( ) : MpdStatistics
return MpdStatistics
        public MpdStatistics Stats()
        {
            MpdResponse response = this.getConnection().Exec("stats");

              if (response.IsError)
            throw new MpdResponseException(response.ErrorCode, response.ErrorMessage);

              int artists = -1;
              int albums = -1;
              int songs = -1;
              int uptime = -1;
              int playtime = -1;
              int db_playtime = -1;
              int db_update = -1;

              foreach (KeyValuePair<string, string> line in response) {
            if ((line.Key != null) && (line.Value != null))
              switch (line.Key) {
            case "artists": {
                int tryValue;
                if (int.TryParse(line.Value, out tryValue))
                  artists = tryValue;
              }
              break;
            case "albums": {
                int tryValue;
                if (int.TryParse(line.Value, out tryValue))
                  albums = tryValue;
              }
              break;
            case "songs": {
                int tryValue;
                if (int.TryParse(line.Value, out tryValue))
                  songs = tryValue;
              }
              break;
            case "uptime": {
                int tryValue;
                if (int.TryParse(line.Value, out tryValue))
                  uptime = tryValue;
              }
              break;
            case "playtime": {
                int tryValue;
                if (int.TryParse(line.Value, out tryValue))
                  playtime = tryValue;
              }
              break;
            case "db_playtime": {
                int tryValue;
                if (int.TryParse(line.Value, out tryValue))
                  db_playtime = tryValue;
              }
              break;
            case "db_update": {
                int tryValue;
                if (int.TryParse(line.Value, out tryValue))
                  db_update = tryValue;
              }
              break;
              }
              }

              return new MpdStatistics(artists, albums, songs, uptime, playtime, db_playtime, db_update);
        }