banshee r3319 - 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 r3319 - in trunk/musicbrainz-sharp: src/MusicBrainz src/MusicBrainz/MusicBrainz tests tests/MusicBrainz.Tests
- Date: Sun, 24 Feb 2008 04:57:24 +0000 (GMT)
Author: scottp
Date: Sun Feb 24 04:57:24 2008
New Revision: 3319
URL: http://svn.gnome.org/viewvc/banshee?rev=3319&view=rev
Log:
Renamed MusicBrainzObject.Mbid to just Id.
* src/MusicBrainz/MusicBrainz/MusicBrainzService.cs: Added static class
for containing all static setting pertaining globally to the use of
the library. I think this is more logical than sticking this stuff
in the abstract MusicBrainzObject type.
Added:
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzService.cs
Modified:
trunk/musicbrainz-sharp/src/MusicBrainz/ChangeLog
trunk/musicbrainz-sharp/src/MusicBrainz/Makefile.am
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz.mdp
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Artist.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Label.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs
trunk/musicbrainz-sharp/tests/ChangeLog
trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ArtistTests.cs
trunk/musicbrainz-sharp/tests/MusicBrainz.Tests/ReleaseTests.cs
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/Makefile.am
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/Makefile.am (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/Makefile.am Sun Feb 24 04:57:24 2008
@@ -14,6 +14,7 @@
MusicBrainz/MusicBrainzException.cs \
MusicBrainz/MusicBrainzItem.cs \
MusicBrainz/MusicBrainzObject.cs \
+ MusicBrainz/MusicBrainzService.cs \
MusicBrainz/Query.cs \
MusicBrainz/Relation.cs \
MusicBrainz/Release.cs \
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz.mdp
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz.mdp (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz.mdp Sun Feb 24 04:57:24 2008
@@ -31,6 +31,7 @@
<File name="MusicBrainz/DiscLinux.cs" subtype="Code" buildaction="Compile" />
<File name="MusicBrainz/XmlRequestEventArgs.cs" subtype="Code" buildaction="Compile" />
<File name="MusicBrainz/LocalDisc.cs" subtype="Code" buildaction="Compile" />
+ <File name="MusicBrainz/MusicBrainzService.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
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 Sun Feb 24 04:57:24 2008
@@ -96,7 +96,7 @@
protected override void HandleLoadMissingData ()
{
- Artist artist = new Artist (Mbid, CreateInc ());
+ Artist artist = new Artist (Id, CreateInc ());
type = artist.Type;
base.HandleLoadMissingData (artist);
}
@@ -142,8 +142,8 @@
#region Properties
[Queryable ("arid")]
- public override string Mbid {
- get { return base.Mbid; }
+ public override string Id {
+ get { return base.Id; }
}
[Queryable ("artist")]
@@ -163,7 +163,7 @@
get {
return releases ?? (have_all_releases
? releases = new ReadOnlyCollection<Release> (new Release [0])
- : new Artist (Mbid, artist_release_type).Releases);
+ : new Artist (Id, artist_release_type).Releases);
}
}
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 Sun Feb 24 04:57:24 2008
@@ -44,7 +44,7 @@
protected override void HandleLoadMissingData ()
{
- Label label = new Label (Mbid, CreateInc ());
+ Label label = new Label (Id, CreateInc ());
type = label.Type;
base.HandleLoadMissingData (label);
}
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 Sun Feb 24 04:57:24 2008
@@ -11,7 +11,6 @@
using System.Collections.ObjectModel;
using System.IO;
using System.Net;
-using System.Net.Cache;
using System.Reflection;
using System.Text;
using System.Threading;
@@ -23,8 +22,6 @@
public abstract class MusicBrainzObject
{
- public static string ProviderUrl = @"http://musicbrainz.org/ws/1/";
-
static TimeSpan min_interval = new TimeSpan (0, 0, 1); // 1 second
static DateTime last_accessed;
static readonly object server_mutex = new object ();
@@ -98,7 +95,7 @@
void CreateFromXml (XmlReader reader)
{
reader.Read ();
- mbid = reader ["id"];
+ id = reader ["id"];
byte.TryParse (reader ["ext:score"], out score);
HandleAttributes (reader);
while (reader.Read () && reader.NodeType != XmlNodeType.EndElement) {
@@ -198,9 +195,9 @@
return field_reference ?? new ReadOnlyCollection<T> (new T [0]);
}
- string mbid;
- public virtual string Mbid {
- get { return mbid; }
+ string id;
+ public virtual string Id {
+ get { return id; }
}
byte score;
@@ -236,12 +233,12 @@
public override bool Equals (object obj)
{
MusicBrainzObject mbobj = obj as MusicBrainzObject;
- return mbobj != null && mbobj.GetType ().Equals (GetType ()) && mbobj.Mbid == Mbid;
+ return mbobj != null && mbobj.GetType ().Equals (GetType ()) && mbobj.Id == Id;
}
public override int GetHashCode ()
{
- return (GetType ().Name + Mbid).GetHashCode ();
+ return (GetType ().Name + Id).GetHashCode ();
}
#endregion
@@ -291,8 +288,8 @@
static string CreateUrl (string url_extension, string mbid, string parameters)
{
- StringBuilder builder = new StringBuilder (ProviderUrl.Length + mbid.Length + parameters.Length + 9);
- builder.Append (ProviderUrl);
+ StringBuilder builder = new StringBuilder (MusicBrainzService.ProviderUrl.Length + mbid.Length + parameters.Length + 9);
+ builder.Append (MusicBrainzService.ProviderUrl);
builder.Append (url_extension);
builder.Append ('/');
builder.Append (mbid);
@@ -301,8 +298,6 @@
return builder.ToString ();
}
- public static RequestCachePolicy CachePolicy;
- public static event EventHandler<XmlRequestEventArgs> XmlRequest;
static void XmlProcessingClosure (string url, XmlProcessingDelegate code)
{
Monitor.Enter (server_mutex);
@@ -316,7 +311,7 @@
bool cache_implemented = false;
try {
- request.CachePolicy = CachePolicy;
+ request.CachePolicy = MusicBrainzService.CachePolicy;
cache_implemented = true;
} catch (NotImplementedException) {
}
@@ -345,8 +340,7 @@
bool from_cache = cache_implemented && response.IsFromCache;
- EventHandler<XmlRequestEventArgs> handler = XmlRequest;
- if (handler != null) handler (null, new XmlRequestEventArgs (url, from_cache));
+ MusicBrainzService.OnXmlRequest (url, from_cache);
if (from_cache) Monitor.Exit (server_mutex);
Added: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzService.cs
==============================================================================
--- (empty file)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzService.cs Sun Feb 24 04:57:24 2008
@@ -0,0 +1,26 @@
+/***************************************************************************
+ * MusicBrainzService.cs
+ *
+ * Authored by Scott Peterson <lunchtimemama gmail com>
+ *
+ * The author disclaims copyright to this source code.
+ ****************************************************************************/
+
+using System;
+using System.Net.Cache;
+
+namespace MusicBrainz
+{
+ public static class MusicBrainzService
+ {
+ public static string ProviderUrl = @"http://musicbrainz.org/ws/1/";
+ public static RequestCachePolicy CachePolicy;
+ public static event EventHandler<XmlRequestEventArgs> XmlRequest;
+
+ internal static void OnXmlRequest (string url, bool fromCache)
+ {
+ EventHandler<XmlRequestEventArgs> handler = XmlRequest;
+ if (handler != null) handler (null, new XmlRequestEventArgs (url, fromCache));
+ }
+ }
+}
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 Sun Feb 24 04:57:24 2008
@@ -154,7 +154,7 @@
protected override void HandleLoadMissingData ()
{
- Release release = new Release (Mbid, CreateInc ());
+ Release release = new Release (Id, CreateInc ());
type = release.Type;
status = release.Status;
language = release.Language;
@@ -241,8 +241,8 @@
#region Properties
[Queryable ("reid")]
- public override string Mbid {
- get { return base.Mbid; }
+ public override string Id {
+ get { return base.Id; }
}
[Queryable ("release")]
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 Sun Feb 24 04:57:24 2008
@@ -107,7 +107,7 @@
protected override void HandleLoadMissingData ()
{
- Track track = new Track (Mbid, CreateInc ());
+ Track track = new Track (Id, CreateInc ());
duration = track.Duration;
if (releases == null) releases = track.Releases;
if (puids == null) puids = track.Puids;
@@ -160,8 +160,8 @@
#region Properties
[Queryable ("trid")]
- public override string Mbid {
- get { return base.Mbid; }
+ public override string Id {
+ get { return base.Id; }
}
[Queryable ("track")]
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 Sun Feb 24 04:57:24 2008
@@ -17,7 +17,7 @@
{
Query<Artist> results = Artist.QueryLucene("artist:" + goodshirt_name);
Assert.AreEqual(1, results.Count);
- Assert.AreEqual(goodshirt_mbid, results[0].Mbid);
+ Assert.AreEqual(goodshirt_mbid, results[0].Id);
}
[Test]
@@ -25,7 +25,7 @@
{
Query<Artist> results = Artist.Query(goodshirt_name);
Assert.IsTrue(results.Count > 0);
- Assert.AreEqual(goodshirt_mbid, results[0].Mbid);
+ Assert.AreEqual(goodshirt_mbid, results[0].Id);
}
[Test]
@@ -33,7 +33,7 @@
{
Artist result = Artist.Query(goodshirt_name);
Assert.IsNotNull(result);
- Assert.AreEqual(goodshirt_mbid, result.Mbid);
+ Assert.AreEqual(goodshirt_mbid, result.Id);
}
[Test]
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 Sun Feb 24 04:57:24 2008
@@ -23,7 +23,7 @@
{
Query<Release> results = Release.Query(fiji_baby_name);
Assert.IsTrue(results.Count > 0);
- Assert.AreEqual(results[0].Mbid, fiji_baby_mbid);
+ Assert.AreEqual(results[0].Id, fiji_baby_mbid);
}
[Test]
@@ -31,7 +31,7 @@
{
Query<Release> results = Release.Query("Classics", "Ratatat");
Assert.IsTrue(results.Count > 0);
- Assert.AreEqual(results[0].Mbid, "82a6769a-6527-4559-8d19-dbfbf93c92f1");
+ Assert.AreEqual(results[0].Id, "82a6769a-6527-4559-8d19-dbfbf93c92f1");
}
[Test]
@@ -60,7 +60,7 @@
p.Asin = "B0001JXMTG";
Query<Release> results = Release.Query(p);
Assert.AreEqual(results.Count, 1);
- Assert.AreEqual(results[0].Mbid, fiji_baby_mbid);
+ Assert.AreEqual(results[0].Id, fiji_baby_mbid);
}
[Test]
@@ -70,7 +70,7 @@
p.DiscID = "p_R7uoqwl1zVO2UtXliPnky1Ov8-";
Query<Release> results = Release.Query(p);
Assert.AreEqual(results.Count, 1);
- Assert.AreEqual(results[0].Mbid, fiji_baby_mbid);
+ Assert.AreEqual(results[0].Id, fiji_baby_mbid);
}
[Test]
@@ -95,7 +95,7 @@
{
Release result = Release.Query(fiji_baby_name);
Assert.IsNotNull(result);
- Assert.AreEqual(result.Mbid, fiji_baby_mbid);
+ Assert.AreEqual(result.Id, fiji_baby_mbid);
}
[Test]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]