banshee r3776 - in trunk/musicbrainz-sharp: src/MusicBrainz src/MusicBrainz/MusicBrainz tests tests/MusicBrainz.Tests
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3776 - in trunk/musicbrainz-sharp: src/MusicBrainz src/MusicBrainz/MusicBrainz tests tests/MusicBrainz.Tests
- Date: Tue, 15 Apr 2008 21:28:48 +0100 (BST)
Author: scottp
Date: Tue Apr 15 21:28:47 2008
New Revision: 3776
URL: http://svn.gnome.org/viewvc/banshee?rev=3776&view=rev
Log:
* src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs,
src/MusicBrainz/MusicBrainz/Relation.cs,
src/MusicBrainz/MusicBrainz/Label.cs,
src/MusicBrainz/MusicBrainz/Release.cs,
src/MusicBrainz/MusicBrainz/Event.cs,
src/MusicBrainz/MusicBrainz/Disc.cs,
src/MusicBrainz/MusicBrainz/MusicBrainzEntity.cs,
src/MusicBrainz/MusicBrainz/XmlRequestEventArgs.cs,
src/MusicBrainz/MusicBrainz/LocalDisc.cs,
src/MusicBrainz/MusicBrainz/Utils.cs,
src/MusicBrainz/MusicBrainz/LinuxDisc.cs,
src/MusicBrainz/MusicBrainz/Track.cs,
src/MusicBrainz/MusicBrainz/MusicBrainzException.cs,
src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs,
src/MusicBrainz/MusicBrainz/Query.cs,
src/MusicBrainz/MusicBrainz/Win32Disc.cs,
src/MusicBrainz/MusicBrainz/Artist.cs,
src/MusicBrainz/MusicBrainz/MusicBrainzService.cs,
tests/MusicBrainz.Tests/ReleaseTests.cs,
tests/MusicBrainz.Tests/TrackTests.cs,
tests/MusicBrainz.Tests/ArtistTests.cs: API BREAKING CHANGE!!! We
now use methods rather than properties if accessing the member can
incur an HTTP request. Update your code accordingly.
Modified:
trunk/musicbrainz-sharp/src/MusicBrainz/ChangeLog
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Artist.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Disc.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Event.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Label.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LinuxDisc.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LocalDisc.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzEntity.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzException.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzService.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Relation.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Win32Disc.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/XmlRequestEventArgs.cs
trunk/musicbrainz-sharp/tests/ChangeLog
trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ArtistTests.cs
trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs
trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/TrackTests.cs
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Artist.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Artist.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Artist.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Artist.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -83,7 +79,7 @@
protected override void LoadMissingDataCore ()
{
Artist artist = new Artist (Id, CreateInc ());
- type = artist.Type;
+ type = artist.GetArtistType ();
base.LoadMissingDataCore (artist);
}
@@ -127,7 +123,7 @@
#endregion
- #region Properties
+ #region Public
public static ArtistReleaseType DefaultArtistReleaseType =
new ArtistReleaseType (ReleaseStatus.Official, false);
@@ -135,6 +131,9 @@
public ArtistReleaseType ArtistReleaseType {
get { return artist_release_type; }
set {
+ if (artist_release_type.Equals (value)) {
+ return;
+ }
artist_release_type = value;
releases = null;
have_all_releases = false;
@@ -147,21 +146,28 @@
}
[Queryable ("artist")]
- public override string Name {
- get { return base.Name; }
+ public override string GetName ()
+ {
+ return base.GetName ();
}
[Queryable ("artype")]
- public ArtistType Type {
- get { return GetPropertyOrDefault (ref type, ArtistType.Unknown); }
+ public ArtistType GetArtistType ()
+ {
+ return GetPropertyOrDefault (ref type, ArtistType.Unknown);
+ }
+
+ public ReadOnlyCollection<Release> GetReleases ()
+ {
+ return GetReleases (artist_release_type);
}
- public ReadOnlyCollection<Release> Releases {
- get {
- return releases ?? (have_all_releases
- ? releases = new ReadOnlyCollection<Release> (new Release [0])
- : new Artist (Id, artist_release_type).Releases);
- }
+ public ReadOnlyCollection<Release> GetReleases (ArtistReleaseType artistReleaseType)
+ {
+ ArtistReleaseType = artistReleaseType;
+ return releases ?? (have_all_releases
+ ? releases = new ReadOnlyCollection<Release> (new Release [0])
+ : new Artist (Id, artistReleaseType).GetReleases ());
}
#endregion
@@ -243,6 +249,16 @@
return str;
}
+ public override bool Equals (object o)
+ {
+ ArtistReleaseType art = o as ArtistReleaseType;
+ return art != null && art.str == str;
+ }
+
+ public override int GetHashCode ()
+ {
+ return str.GetHashCode ();
+ }
}
#endregion
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Disc.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Disc.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Disc.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Disc.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Xml;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Event.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Event.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Event.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Event.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Xml;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Label.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Label.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Label.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Label.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Text;
using System.Xml;
@@ -66,7 +62,7 @@
protected override void LoadMissingDataCore ()
{
Label label = new Label (Id, CreateInc ());
- type = label.Type;
+ type = label.GetLabelType ();
base.LoadMissingDataCore (label);
}
@@ -94,14 +90,16 @@
#endregion
- #region Properties
+ #region Public
- public string Country {
- get { return GetPropertyOrNull (ref country); }
+ public string GetCountry ()
+ {
+ return GetPropertyOrNull (ref country);
}
- public LabelType Type {
- get { return GetPropertyOrDefault (ref type, LabelType.None); }
+ public LabelType GetLabelType ()
+ {
+ return GetPropertyOrDefault (ref type, LabelType.None);
}
#endregion
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LinuxDisc.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LinuxDisc.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LinuxDisc.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// LinuxDisc.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Runtime.InteropServices;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LocalDisc.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LocalDisc.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/LocalDisc.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// LocalDisc.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Security.Cryptography;
using System.Text;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzEntity.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzEntity.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzEntity.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// MusicBrainzEntity.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -69,12 +65,12 @@
protected void LoadMissingDataCore (MusicBrainzEntity entity)
{
- name = entity.Name;
- sort_name = entity.SortName;
- disambiguation = entity.Disambiguation;
- begin_date = entity.BeginDate;
- end_date = entity.EndDate;
- if (aliases == null) aliases = entity.Aliases;
+ name = entity.GetName ();
+ sort_name = entity.GetSortName ();
+ disambiguation = entity.GetDisambiguation ();
+ begin_date = entity.GetBeginDate ();
+ end_date = entity.GetEndDate ();
+ if (aliases == null) aliases = entity.GetAliases ();
base.LoadMissingDataCore (entity);
}
@@ -129,40 +125,42 @@
#endregion
- #region Properties
+ #region Public
- public virtual string Name {
- get { return GetPropertyOrNull (ref name); }
+ public virtual string GetName ()
+ {
+ return GetPropertyOrNull (ref name);
}
- [Queryable]
- public virtual string SortName {
- get { return GetPropertyOrNull (ref sort_name); }
+ [Queryable ("sortname")]
+ public virtual string GetSortName ()
+ {
+ return GetPropertyOrNull (ref sort_name);
}
[Queryable ("comment")]
- public virtual string Disambiguation {
- get { return GetPropertyOrNull (ref disambiguation); }
+ public virtual string GetDisambiguation ()
+ {
+ return GetPropertyOrNull (ref disambiguation);
}
[Queryable ("begin")]
- public virtual string BeginDate {
- get { return GetPropertyOrNull (ref begin_date); }
+ public virtual string GetBeginDate ()
+ {
+ return GetPropertyOrNull (ref begin_date);
}
[Queryable ("end")]
- public virtual string EndDate {
- get { return GetPropertyOrNull (ref end_date); }
+ public virtual string GetEndDate ()
+ {
+ return GetPropertyOrNull (ref end_date);
}
[QueryableMember ("Contains", "alias")]
- public virtual ReadOnlyCollection<string> Aliases {
- get { return GetPropertyOrNew (ref aliases); }
+ public virtual ReadOnlyCollection<string> GetAliases ()
+ {
+ return GetPropertyOrNew (ref aliases);
}
-
- #endregion
-
- #region Public
public override string ToString ()
{
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzException.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzException.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzException.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// MusicBrainzException.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
namespace MusicBrainz
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// MusicBrainzItem.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Text;
using System.Xml;
@@ -64,8 +60,8 @@
protected void LoadMissingDataCore (MusicBrainzItem item)
{
- title = item.Title;
- if (artist == null) artist = item.Artist;
+ title = item.GetTitle ();
+ if (artist == null) artist = item.GetArtist ();
base.LoadMissingDataCore (item);
}
@@ -90,21 +86,19 @@
#endregion
- #region Properties
+ #region Public
- public virtual string Title {
- get { return GetPropertyOrNull (ref title); }
+ public virtual string GetTitle ()
+ {
+ return GetPropertyOrNull (ref title);
}
[Queryable ("artist")]
- public virtual Artist Artist {
- get { return GetPropertyOrNull (ref artist); }
+ public virtual Artist GetArtist ()
+ {
+ return GetPropertyOrNull (ref artist);
}
- #endregion
-
- #region Public
-
public override string ToString ()
{
return title;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// MusicBrainzObject.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -211,23 +207,14 @@
protected void LoadMissingDataCore (MusicBrainzObject obj)
{
if (!all_rels_loaded) {
- artist_rels = obj.ArtistRelations;
- release_rels = obj.ReleaseRelations;
- track_rels = obj.TrackRelations;
- label_rels = obj.LabelRelations;
- url_rels = obj.UrlRelations;
+ artist_rels = obj.GetArtistRelations ();
+ release_rels = obj.GetReleaseRelations ();
+ track_rels = obj.GetTrackRelations ();
+ label_rels = obj.GetLabelRelations ();
+ url_rels = obj.GetUrlRelations ();
}
}
- protected abstract void LoadMissingDataCore ();
- protected abstract bool ProcessAttributes (XmlReader reader);
- protected abstract bool ProcessXml (XmlReader reader);
- protected abstract string UrlExtension { get; }
-
- #endregion
-
- #region Properties
-
protected T GetPropertyOrNull<T> (ref T field_reference) where T : class
{
if (field_reference == null) LoadMissingData ();
@@ -250,6 +237,15 @@
if (field_reference == null && condition) LoadMissingData ();
return field_reference ?? new ReadOnlyCollection<T> (new T [0]);
}
+
+ protected abstract void LoadMissingDataCore ();
+ protected abstract bool ProcessAttributes (XmlReader reader);
+ protected abstract bool ProcessXml (XmlReader reader);
+ protected abstract string UrlExtension { get; }
+
+ #endregion
+
+ #region Public
public virtual string Id {
get { return id; }
@@ -259,29 +255,30 @@
get { return score; }
}
- public virtual ReadOnlyCollection<Relation<Artist>> ArtistRelations {
- get { return GetPropertyOrNew (ref artist_rels, !all_rels_loaded); }
+ public virtual ReadOnlyCollection<Relation<Artist>> GetArtistRelations ()
+ {
+ return GetPropertyOrNew (ref artist_rels, !all_rels_loaded);
}
- public virtual ReadOnlyCollection<Relation<Release>> ReleaseRelations {
- get { return GetPropertyOrNew (ref release_rels, !all_rels_loaded); }
+ public virtual ReadOnlyCollection<Relation<Release>> GetReleaseRelations ()
+ {
+ return GetPropertyOrNew (ref release_rels, !all_rels_loaded);
}
- public virtual ReadOnlyCollection<Relation<Track>> TrackRelations {
- get { return GetPropertyOrNew (ref track_rels, !all_rels_loaded); }
+ public virtual ReadOnlyCollection<Relation<Track>> GetTrackRelations ()
+ {
+ return GetPropertyOrNew (ref track_rels, !all_rels_loaded);
}
- public virtual ReadOnlyCollection<Relation<Label>> LabelRelations {
- get { return GetPropertyOrNew (ref label_rels, !all_rels_loaded); }
+ public virtual ReadOnlyCollection<Relation<Label>> GetLabelRelations ()
+ {
+ return GetPropertyOrNew (ref label_rels, !all_rels_loaded);
}
- public virtual ReadOnlyCollection<UrlRelation> UrlRelations {
- get { return GetPropertyOrNew (ref url_rels, !all_rels_loaded); }
+ public virtual ReadOnlyCollection<UrlRelation> GetUrlRelations ()
+ {
+ return GetPropertyOrNew (ref url_rels, !all_rels_loaded);
}
-
- #endregion
-
- #region Public Methods
public override bool Equals (object obj)
{
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzService.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzService.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzService.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// MusicBrainzService.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Net.Cache;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Query.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Query.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Collections;
using System.Collections.Generic;
@@ -175,22 +171,17 @@
}
- [AttributeUsage (AttributeTargets.Property)]
+ [AttributeUsage (AttributeTargets.Method | AttributeTargets.Property)]
internal sealed class QueryableAttribute : Attribute
{
public readonly string Name;
-
- public QueryableAttribute ()
- {
- }
-
public QueryableAttribute (string name)
{
Name = name;
}
}
- [AttributeUsage (AttributeTargets.Property)]
+ [AttributeUsage (AttributeTargets.Method | AttributeTargets.Property)]
internal sealed class QueryableMemberAttribute : Attribute
{
public readonly string Name;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Relation.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Relation.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Relation.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Relation.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,9 +20,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
+using System.Collections.ObjectModel;
namespace MusicBrainz
{
@@ -32,7 +29,7 @@
{
T target;
string type;
- string [] attributes;
+ ReadOnlyCollection<string> attributes;
RelationDirection direction;
string begin;
string end;
@@ -45,7 +42,7 @@
this.direction = direction;
this.begin = begin;
this.end = end;
- this.attributes = attributes;
+ this.attributes = new ReadOnlyCollection<string> (attributes ?? new string [0]);
}
public T Target {
@@ -56,7 +53,7 @@
get { return type; }
}
- public string [] Attributes {
+ public ReadOnlyCollection<string> Attributes {
get { return attributes; }
}
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Release.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -66,7 +62,7 @@
#endregion
- #region Protected Overrides
+ #region Protected
protected override string UrlExtension {
get { return EXTENSION; }
@@ -88,14 +84,14 @@
protected override void LoadMissingDataCore ()
{
Release release = new Release (Id, CreateInc ());
- type = release.Type;
- status = release.Status;
- language = release.Language;
- script = release.Script;
- asin = release.Asin;
- events = release.Events;
- if (discs == null) discs = release.Discs;
- if (tracks == null) tracks = release.Tracks;
+ type = release.GetReleaseType ();
+ status = release.GetReleaseStatus ();
+ language = release.GetLanguage ();
+ script = release.GetScript ();
+ asin = release.GetAsin ();
+ events = release.GetEvents ();
+ if (discs == null) discs = release.GetDiscs ();
+ if (tracks == null) tracks = release.GetTracks ();
base.LoadMissingDataCore (release);
}
@@ -155,7 +151,7 @@
track_number = int.Parse (offset) + 1;
if (reader.ReadToDescendant ("track")) {
List<Track> tracks = new List<Track> ();
- do tracks.Add (new Track (reader.ReadSubtree (), Artist, AllDataLoaded));
+ do tracks.Add (new Track (reader.ReadSubtree (), GetArtist (), AllDataLoaded));
while (reader.ReadToNextSibling ("track"));
this.tracks = tracks.AsReadOnly ();
}
@@ -173,7 +169,7 @@
#endregion
- #region Properties
+ #region Public
[Queryable ("reid")]
public override string Id {
@@ -181,46 +177,55 @@
}
[Queryable ("release")]
- public override string Title {
- get { return base.Title; }
+ public override string GetTitle ()
+ {
+ return base.GetTitle ();
}
- [Queryable]
- public ReleaseType Type {
- get { return GetPropertyOrDefault (ref type, ReleaseType.None); }
+ [Queryable ("type")]
+ public ReleaseType GetReleaseType ()
+ {
+ return GetPropertyOrDefault (ref type, ReleaseType.None);
}
- [Queryable]
- public ReleaseStatus Status {
- get { return GetPropertyOrDefault (ref status, ReleaseStatus.None); }
+ [Queryable ("status")]
+ public ReleaseStatus GetReleaseStatus ()
+ {
+ return GetPropertyOrDefault (ref status, ReleaseStatus.None);
}
- public string Language {
- get { return GetPropertyOrNull (ref language); }
+ public string GetLanguage ()
+ {
+ return GetPropertyOrNull (ref language);
}
- [Queryable]
- public string Script {
- get { return GetPropertyOrNull (ref script); }
+ [Queryable ("script")]
+ public string GetScript ()
+ {
+ return GetPropertyOrNull (ref script);
}
- [Queryable]
- public string Asin {
- get { return GetPropertyOrNull (ref asin); }
+ [Queryable ("asin")]
+ public string GetAsin ()
+ {
+ return GetPropertyOrNull (ref asin);
}
[QueryableMember("Count", "discids")]
- public ReadOnlyCollection<Disc> Discs {
- get { return GetPropertyOrNew (ref discs); }
+ public ReadOnlyCollection<Disc> GetDiscs ()
+ {
+ return GetPropertyOrNew (ref discs);
}
- public ReadOnlyCollection<Event> Events {
- get { return GetPropertyOrNew (ref events); }
+ public ReadOnlyCollection<Event> GetEvents ()
+ {
+ return GetPropertyOrNew (ref events);
}
[QueryableMember ("Count", "tracks")]
- public ReadOnlyCollection<Track> Tracks {
- get { return GetPropertyOrNew (ref tracks); }
+ public ReadOnlyCollection<Track> GetTracks ()
+ {
+ return GetPropertyOrNew (ref tracks);
}
internal int TrackNumber {
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Track.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -64,7 +60,7 @@
#endregion
- #region Protected Overrides
+ #region Protected
protected override string UrlExtension {
get { return EXTENSION; }
@@ -80,9 +76,9 @@
protected override void LoadMissingDataCore ()
{
Track track = new Track (Id, CreateInc ());
- duration = track.Duration;
- if (releases == null) releases = track.Releases;
- if (puids == null) puids = track.Puids;
+ duration = track.GetDuration ();
+ if (releases == null) releases = track.GetReleases ();
+ if (puids == null) puids = track.GetPuids ();
base.LoadMissingDataCore (track);
}
@@ -131,7 +127,7 @@
#endregion
- #region Properties
+ #region Public
[Queryable ("trid")]
public override string Id {
@@ -139,30 +135,33 @@
}
[Queryable ("track")]
- public override string Title {
- get { return base.Title; }
+ public override string GetTitle ()
+ {
+ return base.GetTitle ();
}
[Queryable ("dur")]
- public uint Duration {
- get { return duration; }
+ public uint GetDuration ()
+ {
+ return duration;
}
[QueryableMember ("Contains", "release")]
- public ReadOnlyCollection<Release> Releases {
- get { return GetPropertyOrNew (ref releases); }
-
+ public ReadOnlyCollection<Release> GetReleases ()
+ {
+ return GetPropertyOrNew (ref releases);
}
- public ReadOnlyCollection<string> Puids {
- get { return GetPropertyOrNew (ref puids); }
+ public ReadOnlyCollection<string> GetPuids ()
+ {
+ return GetPropertyOrNew (ref puids);
}
public int GetTrackNumber (Release release)
{
if (release == null) throw new ArgumentNullException ("release");
- foreach (Release r in Releases)
+ foreach (Release r in GetReleases ())
if (r.Equals (release))
return r.TrackNumber;
return -1;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Utils.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Text;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Win32Disc.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Win32Disc.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Win32Disc.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// Win32Disc.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
using System.Runtime.InteropServices;
using System.Text;
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/XmlRequestEventArgs.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/XmlRequestEventArgs.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/XmlRequestEventArgs.cs Tue Apr 15 21:28:47 2008
@@ -1,5 +1,3 @@
-#region License
-
// XmlRequestEventArgs.cs
//
// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
@@ -22,8 +20,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#endregion
-
using System;
namespace MusicBrainz
Modified: trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ArtistTests.cs
==============================================================================
--- trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ArtistTests.cs (original)
+++ trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ArtistTests.cs Tue Apr 15 21:28:47 2008
@@ -41,7 +41,7 @@
{
Query<Artist> query = Artist.Query("MusicBrainzTestThisShouldFail");
foreach(Artist result in query)
- Assert.IsNotNull(result.Name);
+ Assert.IsNotNull(result.GetName ());
}
[Test]
@@ -55,21 +55,21 @@
public void Get()
{
Artist artist = Artist.Get(goodshirt_mbid);
- Assert.AreEqual(artist.Name, goodshirt_name);
+ Assert.AreEqual(artist.GetName (), goodshirt_name);
}
[Test]
public void GetAndCheckDefaultReleaseCount()
{
Artist artist = Artist.Get(goodshirt_mbid);
- Assert.AreEqual(artist.Releases.Count, 2); // If this fails, make sure they haven't gotten back together to release a new album. If they have, LET ME KNOW! -Scott
+ Assert.AreEqual(artist.GetReleases ().Count, 2); // If this fails, make sure they haven't gotten back together to release a new album. If they have, LET ME KNOW! -Scott
}
[Test]
public void QuerySingleAndCheckDefaultReleaseCount()
{
Artist result = Artist.Query(goodshirt_name);
- Assert.AreEqual(result.Releases.Count, 2);
+ Assert.AreEqual(result.GetReleases ().Count, 2);
}
[Test]
@@ -77,7 +77,7 @@
{
Artist artist = Artist.Get(goodshirt_mbid);
artist.ArtistReleaseType = new ArtistReleaseType(ReleaseStatus.Promotion, true);
- Assert.AreEqual(artist.Releases.Count, 1);
+ Assert.AreEqual(artist.GetReleases ().Count, 1);
}
[Test]
@@ -85,16 +85,16 @@
{
Artist artist = Artist.Get(goodshirt_mbid);
artist.ArtistReleaseType = new ArtistReleaseType(ReleaseType.Live, true);
- Assert.AreEqual(artist.Releases.Count, 1);
+ Assert.AreEqual(artist.GetReleases ().Count, 1);
}
[Test]
public void GetAndCheckDefaultAndCustomReleaseCount()
{
Artist artist = Artist.Get(goodshirt_mbid);
- Assert.AreEqual(artist.Releases.Count, 2);
+ Assert.AreEqual(artist.GetReleases ().Count, 2);
artist.ArtistReleaseType = new ArtistReleaseType(ReleaseType.Live, true);
- Assert.AreEqual(artist.Releases.Count, 1);
+ Assert.AreEqual(artist.GetReleases ().Count, 1);
}
[Test]
@@ -102,22 +102,22 @@
{
Artist artist = Artist.Get(goodshirt_mbid);
artist.ArtistReleaseType = new ArtistReleaseType(ReleaseType.Audiobook, false);
- Assert.AreEqual(artist.Releases.Count, 0);
+ Assert.AreEqual(artist.GetReleases ().Count, 0);
}
[Test]
public void GetAndCheckAliases()
{
Artist artist = Artist.Get(goodshirt_mbid);
- Assert.AreEqual(artist.Aliases.Count, 1);
- Assert.AreEqual(artist.Aliases[0], "Goodshit");
+ Assert.AreEqual(artist.GetAliases ().Count, 1);
+ Assert.AreEqual(artist.GetAliases ()[0], "Goodshit");
}
[Test]
public void GetAndCheckType()
{
Artist artist = Artist.Get(goodshirt_mbid);
- Assert.AreEqual(artist.Type, ArtistType.Group);
+ Assert.AreEqual(artist.GetArtistType (), ArtistType.Group);
}
// WARNING this test is particularly susceptible to database change.
@@ -125,7 +125,7 @@
public void GetAndCheckDisambiguation()
{
Artist artist = Artist.Get("9101e9de-1419-4e22-89ee-2737b7729653");
- Assert.AreEqual(artist.Disambiguation, "Thrash/death metal band from Franconia (Germany)");
+ Assert.AreEqual(artist.GetDisambiguation (), "Thrash/death metal band from Franconia (Germany)");
}
[Test]
@@ -133,7 +133,7 @@
{
Artist artist = Artist.Get("95e1ead9-4d31-4808-a7ac-32c3614c116b");
Assert.IsNotNull(artist);
- Assert.AreEqual(artist.SortName, "Killers, The");
+ Assert.AreEqual(artist.GetSortName (), "Killers, The");
}
[Test]
@@ -141,15 +141,15 @@
{
Artist artist = Artist.Query("The Beatles");
Assert.IsNotNull(artist);
- Assert.AreEqual(artist.BeginDate, "1957");
- Assert.AreEqual(artist.EndDate, "1970-04-10");
+ Assert.AreEqual(artist.GetBeginDate (), "1957");
+ Assert.AreEqual(artist.GetEndDate (), "1970-04-10");
}
[Test]
public void ReleasePreFetching()
{
Artist artist = Artist.Get(goodshirt_mbid);
- Assert.IsNotNull(artist.Releases);
+ Assert.IsNotNull(artist.GetReleases ());
Assert.AreEqual(xml_request_count, 1);
}
Modified: trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs
==============================================================================
--- trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs (original)
+++ trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs Tue Apr 15 21:28:47 2008
@@ -15,7 +15,7 @@
public void Get()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.AreEqual(release.Title, fiji_baby_name);
+ Assert.AreEqual(release.GetTitle (), fiji_baby_name);
}
[Test]
@@ -109,14 +109,14 @@
public void GetAndCheckTrackCount()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.AreEqual(release.Tracks.Count, 11);
+ Assert.AreEqual(release.GetTracks ().Count, 11);
}
[Test]
public void GetAndCheckTrackLevelRelsPreFetching1()
{
Release release = Release.Get("10c60b89-91ba-4bf8-91cd-76d9e9497656"); // Love Their Country
- Assert.IsTrue(release.Tracks[0].TrackRelations.Count > 0);
+ Assert.IsTrue(release.GetTracks()[0].GetTrackRelations().Count > 0);
Assert.AreEqual(xml_request_count, 1);
}
@@ -124,7 +124,7 @@
public void GetAndCheckTrackLevelRelsPreFetching2()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.IsTrue(release.Tracks[0].TrackRelations.Count == 0);
+ Assert.IsTrue(release.GetTracks()[0].GetTrackRelations().Count == 0);
Assert.AreEqual(xml_request_count, 1);
}
@@ -132,7 +132,7 @@
public void QuerySingleAndCheckTrackLevelRels1()
{
Release release = Release.Query("Love Their Country", "Me First and the Gimme Gimmes");
- Assert.IsTrue(release.Tracks[0].TrackRelations.Count > 0);
+ Assert.IsTrue(release.GetTracks()[0].GetTrackRelations().Count > 0);
Assert.AreEqual(xml_request_count, 2);
}
@@ -140,7 +140,7 @@
public void QuerySingleAndCheckTrackLevelRels2()
{
Release release = Release.Query(fiji_baby_name);
- Assert.IsTrue(release.Tracks[0].TrackRelations.Count == 0);
+ Assert.IsTrue(release.GetTracks()[0].GetTrackRelations().Count == 0);
Assert.AreEqual(xml_request_count, 2);
}
@@ -148,73 +148,73 @@
public void GetAndCheckEvents()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.AreEqual(release.Events.Count, 1);
- Assert.AreEqual(release.Events[0].Country, "NZ");
- Assert.AreEqual(release.Events[0].Date, "2004");
- Assert.AreEqual(release.Events[0].Barcode, "724357709026");
- Assert.AreEqual(release.Events[0].Format, ReleaseFormat.CD);
- Assert.AreEqual(release.Events[0].CatalogNumber, "5770902");
+ Assert.AreEqual(release.GetEvents().Count, 1);
+ Assert.AreEqual(release.GetEvents()[0].Country, "NZ");
+ Assert.AreEqual(release.GetEvents()[0].Date, "2004");
+ Assert.AreEqual(release.GetEvents()[0].Barcode, "724357709026");
+ Assert.AreEqual(release.GetEvents()[0].Format, ReleaseFormat.CD);
+ Assert.AreEqual(release.GetEvents()[0].CatalogNumber, "5770902");
}
[Test]
public void QuerySingleAndCheckEvents()
{
Release release = Release.Query(fiji_baby_name);
- Assert.AreEqual(release.Events.Count, 1);
- Assert.AreEqual(release.Events[0].Country, "NZ");
- Assert.AreEqual(release.Events[0].Date, "2004");
- Assert.AreEqual(release.Events[0].Barcode, "724357709026");
- Assert.AreEqual(release.Events[0].Format, ReleaseFormat.CD);
- Assert.AreEqual(release.Events[0].CatalogNumber, "5770902");
+ Assert.AreEqual(release.GetEvents().Count, 1);
+ Assert.AreEqual(release.GetEvents()[0].Country, "NZ");
+ Assert.AreEqual(release.GetEvents()[0].Date, "2004");
+ Assert.AreEqual(release.GetEvents()[0].Barcode, "724357709026");
+ Assert.AreEqual(release.GetEvents()[0].Format, ReleaseFormat.CD);
+ Assert.AreEqual(release.GetEvents()[0].CatalogNumber, "5770902");
}
[Test]
public void GetAndCheckAsin()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.AreEqual(release.Asin, "B0001JXMTG");
+ Assert.AreEqual(release.GetAsin(), "B0001JXMTG");
}
[Test]
public void GetAndCheckDiscs()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.AreEqual(release.Discs.Count, 1);
- Assert.AreEqual(release.Discs[0].Id, "p_R7uoqwl1zVO2UtXliPnky1Ov8-");
- Assert.AreEqual(release.Discs[0].Sectors, 167522);
+ Assert.AreEqual(release.GetDiscs().Count, 1);
+ Assert.AreEqual(release.GetDiscs()[0].Id, "p_R7uoqwl1zVO2UtXliPnky1Ov8-");
+ Assert.AreEqual(release.GetDiscs()[0].Sectors, 167522);
}
[Test]
public void QuerySingleAndCheckDiscs()
{
Release release = Release.Query(fiji_baby_name);
- Assert.AreEqual(release.Discs.Count, 1);
- Assert.AreEqual(release.Discs[0].Id, "p_R7uoqwl1zVO2UtXliPnky1Ov8-");
- Assert.AreEqual(release.Discs[0].Sectors, 167522);
+ Assert.AreEqual(release.GetDiscs().Count, 1);
+ Assert.AreEqual(release.GetDiscs()[0].Id, "p_R7uoqwl1zVO2UtXliPnky1Ov8-");
+ Assert.AreEqual(release.GetDiscs()[0].Sectors, 167522);
}
[Test]
public void GetAndCheckLanguageAndScript()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.AreEqual(release.Language, "ENG");
- Assert.AreEqual(release.Script, "Latn");
+ Assert.AreEqual(release.GetLanguage(), "ENG");
+ Assert.AreEqual(release.GetScript(), "Latn");
}
[Test]
public void GetAndCheckStatusAndType()
{
Release release = Release.Get(fiji_baby_mbid);
- Assert.AreEqual(release.Status, ReleaseStatus.Official);
- Assert.AreEqual(release.Type, ReleaseType.Album);
+ Assert.AreEqual(release.GetReleaseStatus(), ReleaseStatus.Official);
+ Assert.AreEqual(release.GetReleaseType(), ReleaseType.Album);
}
[Test]
public void GetAndCheckSingleArtistParsing()
{
Release release = Release.Get(fiji_baby_mbid);
- foreach(Track track in release.Tracks)
- Assert.IsNotNull(track.Artist.Name);
+ foreach(Track track in release.GetTracks())
+ Assert.IsNotNull(track.GetArtist().GetName());
Assert.AreEqual(xml_request_count, 1);
}
@@ -222,8 +222,8 @@
public void GetAndCheckMultiArtistParsing()
{
Release release = Release.Get("29e85760-d699-47d6-b71b-27b8933e7380");
- foreach(Track track in release.Tracks)
- Assert.IsNotNull(track.Artist.Name);
+ foreach(Track track in release.GetTracks())
+ Assert.IsNotNull(track.GetArtist().GetName());
Assert.AreEqual(xml_request_count, 1);
}
}
Modified: trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/TrackTests.cs
==============================================================================
--- trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/TrackTests.cs (original)
+++ trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/TrackTests.cs Tue Apr 15 21:28:47 2008
@@ -13,7 +13,7 @@
{
Query<Track> query = Track.Query("MusicBrainzQueryThisShouldFail");
foreach(Track result in query)
- Assert.IsNotNull(result.Title);
+ Assert.IsNotNull(result.GetTitle());
}
[Test]
@@ -23,7 +23,7 @@
p.Puid = "2867137f-311b-e9cb-e205-92aa933e8ddd";
Query<Track> query = Track.Query(p);
foreach(Track result in query)
- Assert.IsNotNull(result.Title);
+ Assert.IsNotNull(result.GetTitle());
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]