[banshee: 18/57] Cleaned up UPnPTrackInfo to reuse the constructor to lessen duplicate code
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee: 18/57] Cleaned up UPnPTrackInfo to reuse the constructor to lessen duplicate code
- Date: Mon, 13 Feb 2012 20:29:20 +0000 (UTC)
commit 0d509e14e405f429c3b6aeb500e81833cf41a80b
Author: Tobias Arrskog <topfs2 xbmc org>
Date: Tue Jun 28 12:48:44 2011 +0200
Cleaned up UPnPTrackInfo to reuse the constructor to lessen duplicate code
.../Banshee.UPnPClient/UPnPTrackInfo.cs | 68 +++++++-------------
1 files changed, 24 insertions(+), 44 deletions(-)
---
diff --git a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs
index ed0da49..49c0d9c 100644
--- a/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs
+++ b/src/Extensions/Banshee.UPnPClient/Banshee.UPnPClient/UPnPTrackInfo.cs
@@ -42,60 +42,40 @@ namespace Banshee.UPnPClient
{
static long id = 0;
- public UPnPTrackInfo (AudioItem track, UPnPSource source) : base()
+ public UPnPTrackInfo (MusicTrack track, UPnPSource source) : this (track as AudioItem, source)
{
- if (track != null)
- {
- TrackTitle = track.Title;
-
- if (track.Resources.Count > 0)
- {
- Resource resource = track.Resources[0];
-
- BitRate = (int)resource.BitRate.GetValueOrDefault();
- BitsPerSample = (int)resource.BitsPerSample.GetValueOrDefault();
- Duration = resource.Duration.GetValueOrDefault();
- SampleRate = (int)resource.SampleFrequency.GetValueOrDefault();
- FileSize = (int)resource.Size.GetValueOrDefault();
+ ArtistName = track.Artists.Count > 0 ? track.Artists[0].Name : "";
+ AlbumTitle = track.Albums.Count > 0 ? track.Albums[0] : "";
+
+ TrackNumber = track.OriginalTrackNumber.GetValueOrDefault();
- Uri = new SafeUri(resource.Uri);
- }
- else
- CanPlay = false;
- }
-
- ExternalId = ++id;
-
- PrimarySource = source;
+ Genre = track.Genres.Count > 0 ? track.Genres[0] : "";
}
- public UPnPTrackInfo (MusicTrack track, UPnPSource source) : base()
+ public UPnPTrackInfo (AudioItem track, UPnPSource source) : base ()
{
- if (track != null)
- {
- ArtistName = track.Artists.Count > 0 ? track.Artists[0].Name : "";
- AlbumTitle = track.Albums.Count > 0 ? track.Albums[0] : "";
- TrackTitle = track.Title;
-
- TrackNumber = track.OriginalTrackNumber.GetValueOrDefault();
+ if (track == null)
+ throw new ArgumentNullException("track");
- Genre = track.Genres.Count > 0 ? track.Genres[0] : "";
+ if (source == null)
+ throw new ArgumentNullException("source");
- if (track.Resources.Count > 0)
- {
- Resource resource = track.Resources[0];
+ TrackTitle = track.Title;
+
+ if (track.Resources.Count > 0)
+ {
+ Resource resource = track.Resources[0];
- BitRate = (int)resource.BitRate.GetValueOrDefault();
- BitsPerSample = (int)resource.BitsPerSample.GetValueOrDefault();
- Duration = resource.Duration.GetValueOrDefault();
- SampleRate = (int)resource.SampleFrequency.GetValueOrDefault();
- FileSize = (int)resource.Size.GetValueOrDefault();
+ BitRate = (int)resource.BitRate.GetValueOrDefault();
+ BitsPerSample = (int)resource.BitsPerSample.GetValueOrDefault();
+ Duration = resource.Duration.GetValueOrDefault();
+ SampleRate = (int)resource.SampleFrequency.GetValueOrDefault();
+ FileSize = (int)resource.Size.GetValueOrDefault();
- Uri = new SafeUri(resource.Uri);
- }
- else
- CanPlay = false;
+ Uri = new SafeUri(resource.Uri);
}
+ else
+ CanPlay = false;
ExternalId = ++id;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]