using System.Text; namespace Libmpc { /// /// The MpdStatistics class contains statistics of the MPD file database. /// public class MpdStatistics { private readonly int artists; private readonly int albums; private readonly int songs; private readonly int uptime; private readonly int playtime; private readonly int db_playtime; private readonly long db_update; /// /// The number of artists in the MPD database. /// public int Artists { get { return this.artists; } } /// /// The number of albums in the MPD database. /// public int Albums { get { return this.albums; } } /// /// The number of songs in the MPD database. /// public int Songs { get { return this.songs; } } /// /// The time the MPD server is running in seconds. /// public int Uptime { get { return this.uptime; } } /// /// The number of seconds the MPD played so far. /// public int Playtime { get { return this.playtime; } } /// /// The total playtime of all songs in the MPD database. /// public int DbPlaytime { get { return this.db_playtime; } } /// /// The timestamp of the last MPD database update. /// public long DbUpdate { get { return this.db_update; } } /// /// Creates a new MpdStatistics object. /// /// The number of artists in the MPD database. /// The number of albums in the MPD database. /// The number of songs in the MPD database. /// The time the MPD server is running in seconds. /// The number of seconds the MPD played so far. /// The total playtime of all songs in the MPD database. /// The timestamp of the last MPD database update. public MpdStatistics( int artists, int albums, int songs, int uptime, int playtime, int db_playtime, long db_update ) { this.artists = artists; this.albums = albums; this.songs = songs; this.uptime = uptime; this.playtime = playtime; this.db_playtime = db_playtime; this.db_update = db_update; } /// /// Returns a string representation of the object mainly for debugging purpuse. /// /// A string representation of the object. public override string ToString() { StringBuilder builder = new StringBuilder(); appendInt(builder, "artists", this.artists); appendInt(builder, "songs", this.songs); appendInt(builder, "uptime", this.uptime); appendInt(builder, "playtime", this.playtime); appendInt(builder, "db_playtime", this.db_playtime); appendLong(builder, "db_update", this.db_update); return builder.ToString(); } private static void appendInt(StringBuilder builder, string name, int value) { if (value < 0) return; builder.Append(name); builder.Append(": "); builder.Append(value); builder.AppendLine(); } private static void appendLong(StringBuilder builder, string name, long value) { if (value < 0) return; builder.Append(name); builder.Append(": "); builder.Append(value); builder.AppendLine(); } } }