banshee r3296 - in trunk/musicbrainz-sharp/src/MusicBrainz: . MusicBrainz
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3296 - in trunk/musicbrainz-sharp/src/MusicBrainz: . MusicBrainz
- Date: Thu, 21 Feb 2008 22:07:33 +0000 (GMT)
Author: scottp
Date: Thu Feb 21 22:07:32 2008
New Revision: 3296
URL: http://svn.gnome.org/viewvc/banshee?rev=3296&view=rev
Log:
Whitespace changes. I'll probably work things a little more.
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/DiscLinux.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/DiscWin32.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Event.cs
trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Label.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/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/Utilities.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 Thu Feb 21 22:07:32 2008
@@ -15,33 +15,31 @@
{
public enum ArtistType
{
+ Unknown,
Group,
- Person,
- Unknown
+ Person
}
public sealed class ArtistReleaseType
{
string str;
- public ArtistReleaseType(ReleaseType type, bool various)
- : this((Enum)type, various)
+ public ArtistReleaseType (ReleaseType type, bool various) : this ((Enum)type, various)
{
}
- public ArtistReleaseType(ReleaseStatus status, bool various)
- : this((Enum)status, various)
+ public ArtistReleaseType (ReleaseStatus status, bool various) : this ((Enum)status, various)
{
}
- ArtistReleaseType(Enum enumeration, bool various)
+ ArtistReleaseType (Enum enumeration, bool various)
{
str = various
- ? "va-" + Utilities.EnumToString(enumeration)
- : "sa-" + Utilities.EnumToString(enumeration);
+ ? "va-" + Utilities.EnumToString (enumeration)
+ : "sa-" + Utilities.EnumToString (enumeration);
}
- public override string ToString()
+ public override string ToString ()
{
return str;
}
@@ -51,15 +49,17 @@
public sealed class Artist : MusicBrainzEntity
{
const string EXTENSION = "artist";
- protected override string UrlExtension
- {
+
+ protected override string UrlExtension {
get { return EXTENSION; }
}
- public static ArtistReleaseType DefaultArtistReleaseType = new ArtistReleaseType(ReleaseStatus.Official, false);
+ public static ArtistReleaseType DefaultArtistReleaseType =
+ new ArtistReleaseType (ReleaseStatus.Official, false);
+
ArtistReleaseType artist_release_type = DefaultArtistReleaseType;
- public ArtistReleaseType ArtistReleaseType
- {
+
+ public ArtistReleaseType ArtistReleaseType {
get { return artist_release_type; }
set {
artist_release_type = value;
@@ -68,44 +68,41 @@
}
}
- Artist(string mbid)
- : base(mbid, null)
+ Artist (string mbid) : base (mbid, null)
{
}
- Artist(string mbid, string parameters)
- : base(mbid, parameters)
+ Artist (string mbid, string parameters) : base (mbid, parameters)
{
}
- Artist(string mbid, ArtistReleaseType artist_release_type)
- : this(mbid, "&inc=" + artist_release_type.ToString())
+ Artist (string mbid, ArtistReleaseType artist_release_type)
+ : this (mbid, "&inc=" + artist_release_type.ToString ())
{
have_all_releases = true;
this.artist_release_type = artist_release_type;
}
- internal Artist(XmlReader reader)
- : base(reader, false)
+ internal Artist (XmlReader reader) : base (reader, false)
{
}
- protected override void HandleCreateInc(StringBuilder builder)
+ protected override void HandleCreateInc (StringBuilder builder)
{
- AppendIncParameters(builder, artist_release_type.ToString());
- base.HandleCreateInc(builder);
+ AppendIncParameters (builder, artist_release_type.ToString ());
+ base.HandleCreateInc (builder);
}
- protected override void HandleLoadMissingData()
+ protected override void HandleLoadMissingData ()
{
- Artist artist = new Artist(MBID, CreateInc());
+ Artist artist = new Artist (MBID, CreateInc ());
type = artist.Type;
- base.HandleLoadMissingData(artist);
+ base.HandleLoadMissingData (artist);
}
- protected override bool HandleAttributes(XmlReader reader)
+ protected override bool HandleAttributes (XmlReader reader)
{
- switch(reader["type"]) {
+ switch (reader ["type"]) {
case "Group":
type = ArtistType.Group;
break;
@@ -116,95 +113,85 @@
return type != ArtistType.Unknown;
}
- protected override bool HandleXml(XmlReader reader)
+ protected override bool HandleXml (XmlReader reader)
{
- reader.Read();
- bool result = base.HandleXml(reader);
- if(!result) {
+ reader.Read ();
+ bool result = base.HandleXml (reader);
+ if (!result) {
result = true;
- switch(reader.Name) {
+ switch (reader.Name) {
case "release-list":
- if(reader.ReadToDescendant("release")) {
- releases = new List<Release>();
- do releases.Add(new Release(reader.ReadSubtree()));
- while(reader.ReadToNextSibling("release"));
+ if (reader.ReadToDescendant ("release")) {
+ releases = new List<Release> ();
+ do releases.Add (new Release (reader.ReadSubtree ()));
+ while (reader.ReadToNextSibling ("release"));
}
break;
default:
- reader.Skip(); // FIXME this is a workaround for Mono bug 334752
+ reader.Skip (); // FIXME this is a workaround for Mono bug 334752
result = false;
break;
}
}
- reader.Close();
+ reader.Close ();
return result;
}
#region Properties
- [Queryable("arid")]
- public override string MBID
- {
+ [Queryable ("arid")]
+ public override string MBID {
get { return base.MBID; }
}
- [Queryable("artist")]
- public override string Name
- {
+ [Queryable ("artist")]
+ public override string Name {
get { return base.Name; }
}
ArtistType? type;
- [Queryable("artype")]
- public ArtistType Type
- {
- get { return GetPropertyOrDefault<ArtistType>(ref type, ArtistType.Unknown); }
+ [Queryable ("artype")]
+ public ArtistType Type {
+ get { return GetPropertyOrDefault<ArtistType> (ref type, ArtistType.Unknown); }
}
List<Release> releases;
bool have_all_releases;
- public List<Release> Releases
- {
+ public List<Release> Releases {
get {
return releases ?? (have_all_releases
- ? releases = new List<Release>()
- : new Artist(MBID, artist_release_type).Releases);
+ ? releases = new List<Release> ()
+ : new Artist (MBID, artist_release_type).Releases);
}
}
#endregion
- public static Artist Get(string mbid)
+ public static Artist Get (string mbid)
{
- if(mbid == null)
- throw new ArgumentNullException("mbid");
-
- return new Artist(mbid);
+ if (mbid == null) throw new ArgumentNullException ("mbid");
+ return new Artist (mbid);
}
#region Query
- public static Query<Artist> Query(string name)
+ public static Query<Artist> Query (string name)
{
- if(name == null)
- throw new ArgumentNullException("name");
-
- return new Query<Artist>(EXTENSION, QueryLimit, CreateNameParameter(name));
+ if (name == null) throw new ArgumentNullException ("name");
+ return new Query<Artist> (EXTENSION, QueryLimit, CreateNameParameter (name));
}
- public static Query<Artist> QueryLucene(string lucene_query)
+ public static Query<Artist> QueryLucene (string luceneQuery)
{
- if(lucene_query == null)
- throw new ArgumentNullException("lucene_query");
-
- return new Query<Artist>(EXTENSION, QueryLimit, CreateLuceneParameter(lucene_query));
+ if (luceneQuery == null) throw new ArgumentNullException ("luceneQuery");
+ return new Query<Artist> (EXTENSION, QueryLimit, CreateLuceneParameter (luceneQuery));
}
#endregion
- public static implicit operator string(Artist a)
+ public static implicit operator string (Artist artist)
{
- return a.ToString();
+ return artist.ToString ();
}
}
}
\ No newline at end of file
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 Thu Feb 21 22:07:32 2008
@@ -19,101 +19,88 @@
int sectors;
byte first_track;
byte last_track;
- int[] track_durations;
- int[] track_offsets = new int[100];
+ int [] track_durations;
+ int [] track_offsets = new int [100];
- protected Disc()
+ internal Disc ()
{
}
- internal Disc(XmlReader reader)
+ internal Disc (XmlReader reader)
{
- reader.Read();
- string sectors_string = reader["sectors"];
- if(sectors_string != null)
- sectors = int.Parse(sectors_string);
- id = reader["id"];
- reader.Close();
+ reader.Read ();
+ string sectors_string = reader ["sectors"];
+ if (sectors_string != null)
+ sectors = int.Parse (sectors_string);
+ id = reader ["id"];
+ reader.Close ();
}
- protected void Init()
+ protected void Init ()
{
- track_durations = new int[last_track];
- for(int i = 1; i <= last_track; i++) {
- track_durations[i - 1] = i < last_track
- ? track_offsets[i + 1] - track_offsets[i]
- : track_offsets[0] - track_offsets[i];
- track_durations[i - 1] /= 75; // 75 frames in a second
+ track_durations = new int [last_track];
+ for (int i = 1; i <= last_track; i++) {
+ track_durations [i - 1] = i < last_track
+ ? track_offsets [i + 1] - track_offsets [i]
+ : track_offsets [0] - track_offsets [i];
+ track_durations [i - 1] /= 75; // 75 frames in a second
}
- GenerateId();
+ GenerateId ();
}
- void GenerateId()
+ void GenerateId ()
{
- StringBuilder input_builder = new StringBuilder(804);
- input_builder.Append(string.Format("{0:X2}", FirstTrack));
- input_builder.Append(string.Format("{0:X2}", LastTrack));
- for(int i = 0; i < track_offsets.Length; i++)
- input_builder.Append(string.Format("{0:X8}", track_offsets[i]));
+ StringBuilder input_builder = new StringBuilder (804);
+ input_builder.Append (string.Format ("{0:X2}", FirstTrack));
+ input_builder.Append (string.Format ("{0:X2}", LastTrack));
+ for (int i = 0; i < track_offsets.Length; i++)
+ input_builder.Append (string.Format ("{0:X8}", track_offsets [i]));
// MB uses a slightly modified RFC822 for reasons of URL happiness.
- string base64 = Convert.ToBase64String(SHA1.Create()
- .ComputeHash(Encoding.ASCII.GetBytes(input_builder.ToString())));
- StringBuilder hash_builder = new StringBuilder(base64.Length);
- foreach(char c in base64)
- if(c == '+')
- hash_builder.Append('.');
- else if(c == '/')
- hash_builder.Append('_');
- else if(c == '=')
- hash_builder.Append('-');
- else
- hash_builder.Append(c);
- id = hash_builder.ToString();
+ string base64 = Convert.ToBase64String (SHA1.Create ()
+ .ComputeHash (Encoding.ASCII.GetBytes (input_builder.ToString ())));
+ StringBuilder hash_builder = new StringBuilder (base64.Length);
+ foreach (char c in base64)
+ if (c == '+') hash_builder.Append ('.');
+ else if (c == '/') hash_builder.Append ('_');
+ else if (c == '=') hash_builder.Append ('-');
+ else hash_builder.Append (c);
+ id = hash_builder.ToString ();
}
- public string ID
- {
+ public string ID {
get { return id; }
}
- public int Sectors
- {
+ public int Sectors {
get { return sectors; }
protected set { sectors = value; }
}
- protected byte FirstTrack
- {
+ protected byte FirstTrack {
get { return first_track; }
set { first_track = value; }
}
- protected byte LastTrack
- {
+ protected byte LastTrack {
get { return last_track; }
set { last_track = value; }
}
- protected int[] TrackOffsets
- {
+ protected int [] TrackOffsets {
get { return track_offsets; }
}
- public int[] TrackDurations
- {
+ public int [] TrackDurations {
get { return track_durations; }
}
- public static Disc GetFromDevice(string device)
+ public static Disc GetFromDevice (string device)
{
- if(device == null)
- throw new ArgumentNullException("device");
+ if (device == null) throw new ArgumentNullException ("device");
- if(Environment.OSVersion.Platform != PlatformID.Unix)
- return new DiscWin32(device);
- else
- return new DiscLinux(device);
+ return Environment.OSVersion.Platform != PlatformID.Unix
+ ? (Disc)new DiscWin32 (device) : new DiscLinux (device);
}
}
}
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/DiscLinux.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/DiscLinux.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/DiscLinux.cs Thu Feb 21 22:07:32 2008
@@ -25,31 +25,31 @@
const int CD_FRAMES = 75;
const int XA_INTERVAL = ((60 + 90 + 2) * CD_FRAMES);
- [DllImport("libc.so.6")]
- static extern int open(string path, int flags);
+ [DllImport ("libc.so.6")]
+ static extern int open (string path, int flags);
- [DllImport("libc.so.6")]
- static extern int close(int fd);
+ [DllImport ("libc.so.6")]
+ static extern int close (int fd);
- [DllImport("libc.so.6", EntryPoint = "ioctl")]
- static extern int read_toc_header(int fd, int request, ref cdrom_tochdr header);
- static int read_toc_header(int fd, ref cdrom_tochdr header)
+ [DllImport ("libc.so.6", EntryPoint = "ioctl")]
+ static extern int read_toc_header (int fd, int request, ref cdrom_tochdr header);
+ static int read_toc_header (int fd, ref cdrom_tochdr header)
{
return read_toc_header(fd, CDROMREADTOCHDR, ref header);
}
- [DllImport("libc.so.6", EntryPoint = "ioctl")]
- static extern int read_multisession(int fd, int request, ref cdrom_multisession multisession);
- static int read_multisession(int fd, ref cdrom_multisession multisession)
+ [DllImport ("libc.so.6", EntryPoint = "ioctl")]
+ static extern int read_multisession (int fd, int request, ref cdrom_multisession multisession);
+ static int read_multisession (int fd, ref cdrom_multisession multisession)
{
- return read_multisession(fd, CDROMMULTISESSION, ref multisession);
+ return read_multisession (fd, CDROMMULTISESSION, ref multisession);
}
- [DllImport("libc.so.6", EntryPoint = "ioctl")]
- static extern int read_toc_entry(int fd, int request, ref cdrom_tocentry entry);
- static int read_toc_entry(int fd, ref cdrom_tocentry entry)
+ [DllImport ("libc.so.6", EntryPoint = "ioctl")]
+ static extern int read_toc_entry (int fd, int request, ref cdrom_tocentry entry);
+ static int read_toc_entry (int fd, ref cdrom_tocentry entry)
{
- return read_toc_entry(fd, CDROMREADTOCENTRY, ref entry);
+ return read_toc_entry (fd, CDROMREADTOCENTRY, ref entry);
}
struct cdrom_tochdr
@@ -74,86 +74,78 @@
public byte addr_format;
}
- int ReadTocHeader(int fd)
+ int ReadTocHeader (int fd)
{
- cdrom_tochdr th = new cdrom_tochdr();
- cdrom_multisession ms = new cdrom_multisession();
+ cdrom_tochdr th = new cdrom_tochdr ();
+ cdrom_multisession ms = new cdrom_multisession ();
- int ret = read_toc_header(fd, ref th);
+ int ret = read_toc_header (fd, ref th);
- if(ret < 0)
- return ret;
+ if (ret < 0) return ret;
FirstTrack = th.cdth_trk0;
LastTrack = th.cdth_trk1;
ms.addr_format = CDROM_LBA;
- ret = read_multisession(fd, ref ms);
+ ret = read_multisession (fd, ref ms);
- if(ms.xa_flag != 0)
- LastTrack--;
+ if(ms.xa_flag != 0) LastTrack--;
return ret;
}
- int ReadTocEntry(int fd, byte track_number, ref ulong lba)
+ int ReadTocEntry (int fd, byte track_number, ref ulong lba)
{
- cdrom_tocentry te = new cdrom_tocentry();
+ cdrom_tocentry te = new cdrom_tocentry ();
te.cdte_track = track_number;
te.cdte_format = CDROM_LBA;
- int ret = read_toc_entry(fd, ref te);
+ int ret = read_toc_entry (fd, ref te);
- if(ret == 0)
- lba = (ulong)te.lba;
+ if(ret == 0) lba = (ulong)te.lba;
return ret;
}
- int ReadLeadout(int fd, ref ulong lba)
+ int ReadLeadout (int fd, ref ulong lba)
{
- cdrom_multisession ms = new cdrom_multisession();
+ cdrom_multisession ms = new cdrom_multisession ();
ms.addr_format = CDROM_LBA;
- int ret = read_multisession(fd, ref ms);
+ int ret = read_multisession (fd, ref ms);
- if(ms.xa_flag != 0) {
+ if (ms.xa_flag != 0) {
lba = (ulong)(ms.lba - XA_INTERVAL);
return ret;
}
- return ReadTocEntry(fd, CDROM_LEADOUT, ref lba);
+ return ReadTocEntry (fd, CDROM_LEADOUT, ref lba);
}
- internal DiscLinux(string device)
+ internal DiscLinux (string device)
{
int fd = open(device, O_RDONLY | O_NONBLOCK);
- if(fd < 0)
- throw new Exception(String.Format("Cannot open device '{0}'", device));
+ if (fd < 0)
+ throw new Exception (String.Format ("Cannot open device '{0}'", device));
try {
- if(ReadTocHeader(fd) < 0) {
- throw new Exception("Cannot read table of contents");
- }
-
- if(LastTrack == 0) {
- throw new Exception("This disc has no tracks");
- }
+ if (ReadTocHeader(fd) < 0) throw new Exception ("Cannot read table of contents");
+ if (LastTrack == 0) throw new Exception ("This disc has no tracks");
ulong lba = 0;
- ReadLeadout(fd, ref lba);
- TrackOffsets[0] = (int)lba + 150;
+ ReadLeadout (fd, ref lba);
+ TrackOffsets [0] = (int)lba + 150;
- for(byte i = FirstTrack; i <= LastTrack; i++) {
- ReadTocEntry(fd, i, ref lba);
+ for (byte i = FirstTrack; i <= LastTrack; i++) {
+ ReadTocEntry (fd, i, ref lba);
TrackOffsets[i] = (int)lba + 150;
}
} finally {
- close(fd);
+ close (fd);
}
- Init();
+ Init ();
}
}
}
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/DiscWin32.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/DiscWin32.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/DiscWin32.cs Thu Feb 21 22:07:32 2008
@@ -17,94 +17,92 @@
{
internal sealed class DiscWin32 : Disc
{
- [DllImport("winmm")]
- static extern Int32 mciSendString(String command,
- StringBuilder buffer,
- Int32 bufferSize,
- IntPtr hwndCallback);
-
- [DllImport("winmm")]
- static extern Int32 mciGetErrorString(Int32 errorCode,
- StringBuilder errorText,
- Int32 errorTextSize);
+ [DllImport ("winmm")]
+ static extern Int32 mciSendString (String command,
+ StringBuilder buffer,
+ Int32 bufferSize,
+ IntPtr hwndCallback);
+
+ [DllImport ("winmm")]
+ static extern Int32 mciGetErrorString (Int32 errorCode,
+ StringBuilder errorText,
+ Int32 errorTextSize);
- internal DiscWin32(string device)
+ internal DiscWin32 (string device)
{
string device_string = device.Length == 0
- ? "cdaudio"
- : string.Format("{0} type cdaudio", device);
+ ? "cdaudio" : string.Format ("{0} type cdaudio", device);
- string alias = string.Format("musicbrainz_cdio_{0}_{1}",
+ string alias = string.Format ("musicbrainz_cdio_{0}_{1}",
Environment.TickCount, Thread.CurrentThread.ManagedThreadId);
- MciClosure(
+ MciClosure (
"sysinfo cdaudio quantity wait",
"Could not get the list of CD audio devices",
- delegate(string result) {
- if(int.Parse(result.ToString()) <= 0)
- throw new Exception("No CD audio devices present.");
+ delegate (string result) {
+ if (int.Parse (result.ToString ()) <= 0)
+ throw new Exception ("No CD audio devices present.");
});
- MciClosure(
- string.Format("open {0} shareable alias {1} wait", device_string, alias),
- string.Format("Could not open device {0}", device),
+ MciClosure (
+ string.Format ("open {0} shareable alias {1} wait", device_string, alias),
+ string.Format ("Could not open device {0}", device),
null);
- MciClosure(
- string.Format("status {0} number of tracks wait", alias),
+ MciClosure (
+ string.Format ("status {0} number of tracks wait", alias),
"Could not read number of tracks",
- delegate(string result) {
+ delegate (string result) {
FirstTrack = 1;
- LastTrack = byte.Parse(result);
+ LastTrack = byte.Parse (result);
});
- MciClosure(
- string.Format("set {0} time format msf wait", alias),
+ MciClosure (
+ string.Format ("set {0} time format msf wait", alias),
"Could not set time format",
null);
- for(int i = 1; i <= LastTrack; i++)
- MciClosure(
- string.Format("status {0} position track {1} wait", alias, i),
- string.Format("Could not get position for track {0}", i),
- delegate(string result) {
- TrackOffsets[i] =
- int.Parse(result.Substring(0,2)) * 4500 +
- int.Parse(result.Substring(3,2)) * 75 +
- int.Parse(result.Substring(6,2));
+ for (int i = 1; i <= LastTrack; i++)
+ MciClosure (
+ string.Format ("status {0} position track {1} wait", alias, i),
+ string.Format ("Could not get position for track {0}", i),
+ delegate (string result) {
+ TrackOffsets [i] =
+ int.Parse (result.Substring (0,2)) * 4500 +
+ int.Parse (result.Substring (3,2)) * 75 +
+ int.Parse (result.Substring (6,2));
});
- MciClosure(
- string.Format("status {0} length track {1} wait", alias, LastTrack),
+ MciClosure (
+ string.Format ("status {0} length track {1} wait", alias, LastTrack),
"Could not read the length of the last track",
- delegate(string result) {
- TrackOffsets[0] =
- int.Parse(result.Substring(0, 2)) * 4500 +
- int.Parse(result.Substring(3, 2)) * 75 +
- int.Parse(result.Substring(6, 2)) +
- TrackOffsets[LastTrack] + 1;
+ delegate (string result) {
+ TrackOffsets [0] =
+ int.Parse (result.Substring (0, 2)) * 4500 +
+ int.Parse (result.Substring (3, 2)) * 75 +
+ int.Parse (result.Substring (6, 2)) +
+ TrackOffsets [LastTrack] + 1;
});
- MciClosure(
- string.Format("close {0} wait", alias),
- string.Format("Could not close device {0}", device),
+ MciClosure (
+ string.Format ("close {0} wait", alias),
+ string.Format ("Could not close device {0}", device),
null);
- Init();
+ Init ();
}
- static StringBuilder mci_result = new StringBuilder(128);
- static StringBuilder mci_error = new StringBuilder(256);
- static void MciClosure(string command, string failure_message, MciCall code)
+ static StringBuilder mci_result = new StringBuilder (128);
+ static StringBuilder mci_error = new StringBuilder (256);
+ static void MciClosure (string command, string failure_message, MciCall code)
{
- int ret = mciSendString(command, mci_result, mci_result.Capacity, IntPtr.Zero);
- if(ret != 0) {
- mciGetErrorString(ret, mci_error, mci_error.Capacity);
- throw new Exception(string.Format("{0} : {1}", failure_message, mci_error.ToString()));
- } else if(code != null)
- code(mci_result.ToString());
+ int ret = mciSendString (command, mci_result, mci_result.Capacity, IntPtr.Zero);
+ if (ret != 0) {
+ mciGetErrorString (ret, mci_error, mci_error.Capacity);
+ throw new Exception (string.Format ("{0} : {1}", failure_message, mci_error.ToString ()));
+ } else if (code != null) code (mci_result.ToString ());
}
- delegate void MciCall(string result);
+ delegate void MciCall (string result);
}
}
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 Thu Feb 21 22:07:32 2008
@@ -20,54 +20,48 @@
Label label;
ReleaseFormat format = ReleaseFormat.None;
- internal Event(XmlReader reader)
+ internal Event (XmlReader reader)
{
- reader.Read();
- date = reader["date"];
- country = reader["country"];
- catalog_number = reader["catalog-number"];
- barcode = reader["barcode"];
- string format_string = reader["format"];
- if(format_string != null)
- foreach(ReleaseFormat format in Enum.GetValues(typeof(ReleaseFormat)))
- if(format.ToString() == format_string) {
+ reader.Read ();
+ date = reader ["date"];
+ country = reader ["country"];
+ catalog_number = reader ["catalog-number"];
+ barcode = reader ["barcode"];
+ string format_string = reader ["format"];
+ if (format_string != null)
+ foreach (ReleaseFormat format in Enum.GetValues (typeof (ReleaseFormat)))
+ if (format.ToString () == format_string) {
this.format = format;
break;
}
- if(reader.ReadToDescendant("label")) {
- label = new Label(reader.ReadSubtree());
- reader.Read(); // FIXME this is a workaround for Mono bug 334752
+ if (reader.ReadToDescendant ("label")) {
+ label = new Label (reader.ReadSubtree ());
+ reader.Read (); // FIXME this is a workaround for Mono bug 334752
}
- reader.Close();
+ reader.Close ();
}
- public string Date
- {
+ public string Date {
get { return date; }
}
- public string Country
- {
+ public string Country {
get { return country; }
}
- public string CatalogNumber
- {
+ public string CatalogNumber {
get { return catalog_number; }
}
- public string Barcode
- {
+ public string Barcode {
get { return barcode; }
}
- public Label Label
- {
+ public Label Label {
get { return label; }
}
- public ReleaseFormat Format
- {
+ public ReleaseFormat Format {
get { return format; }
}
}
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 Thu Feb 21 22:07:32 2008
@@ -26,104 +26,92 @@
public sealed class Label : MusicBrainzEntity
{
const string EXTENSION = "label";
- protected override string UrlExtension
- {
+
+ protected override string UrlExtension {
get { return EXTENSION; }
}
- Label(string mbid)
- : base(mbid, null)
+ Label (string mbid) : base (mbid, null)
{
}
- Label(string mbid, string parameters)
- : base(mbid, parameters)
+ Label (string mbid, string parameters) : base (mbid, parameters)
{
}
- internal Label(XmlReader reader)
- : base(reader, false)
+ internal Label (XmlReader reader) : base (reader, false)
{
}
- protected override void HandleLoadMissingData()
+ protected override void HandleLoadMissingData ()
{
- Label label = new Label(MBID, CreateInc());
+ Label label = new Label (MBID, CreateInc ());
type = label.Type;
- base.HandleLoadMissingData(label);
+ base.HandleLoadMissingData (label);
}
- protected override bool HandleAttributes(XmlReader reader)
+ protected override bool HandleAttributes (XmlReader reader)
{
- string type_string = reader["type"];
- foreach(LabelType type in Enum.GetValues(typeof(LabelType)) as LabelType[])
- if(Utilities.EnumToString(type) == type_string) {
+ string type_string = reader ["type"];
+ foreach (LabelType type in Enum.GetValues (typeof (LabelType)) as LabelType [])
+ if (Utilities.EnumToString (type) == type_string) {
this.type = type;
break;
}
return this.type != null;
}
- protected override bool HandleXml(XmlReader reader)
+ protected override bool HandleXml (XmlReader reader)
{
- reader.Read();
- bool result = base.HandleXml(reader);
- if(!result) {
- if(reader.Name == "country") {
+ reader.Read ();
+ bool result = base.HandleXml (reader);
+ if (!result) {
+ if (reader.Name == "country") {
result = true;
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- country = reader.ReadContentAsString();
- } else
- reader.Skip(); // FIXME this is a workaround for Mono bug 334752
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text)
+ country = reader.ReadContentAsString ();
+ } else reader.Skip (); // FIXME this is a workaround for Mono bug 334752
}
- reader.Close();
+ reader.Close ();
return result;
}
string country;
- public string Country
- {
- get { return GetPropertyOrNull<string>(ref country); }
+ public string Country {
+ get { return GetPropertyOrNull<string> (ref country); }
}
LabelType? type;
- public LabelType Type
- {
- get { return GetPropertyOrDefault<LabelType>(ref type, LabelType.Unspecified); }
+ public LabelType Type {
+ get { return GetPropertyOrDefault<LabelType> (ref type, LabelType.Unspecified); }
}
- public static Label Get(string mbid)
+ public static Label Get (string mbid)
{
- if(mbid == null)
- throw new ArgumentNullException("mbid");
-
- return new Label(mbid);
+ if (mbid == null) throw new ArgumentNullException ("mbid");
+ return new Label (mbid);
}
#region Query
- public static Query<Label> Query(string name)
+ public static Query<Label> Query (string name)
{
- if(name == null)
- throw new ArgumentNullException("name");
-
- return new Query<Label>(EXTENSION, QueryLimit, CreateNameParameter(name));
+ if (name == null) throw new ArgumentNullException ("name");
+ return new Query<Label> (EXTENSION, QueryLimit, CreateNameParameter (name));
}
- public static Query<Label> QueryLucene(string lucene_query)
+ public static Query<Label> QueryLucene (string luceneQuery)
{
- if(lucene_query == null)
- throw new ArgumentNullException("lucene_query");
-
- return new Query<Label>(EXTENSION, QueryLimit, CreateLuceneParameter(lucene_query));
+ if (luceneQuery == null) throw new ArgumentNullException ("luceneQuery");
+ return new Query<Label> (EXTENSION, QueryLimit, CreateLuceneParameter (luceneQuery));
}
#endregion
- public static implicit operator string(Label l)
+ public static implicit operator string (Label label)
{
- return l.ToString();
+ return label.ToString ();
}
}
}
\ No newline at end of file
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 Thu Feb 21 22:07:32 2008
@@ -16,66 +16,59 @@
// A person-like entity, such as an artist or a label.
public abstract class MusicBrainzEntity : MusicBrainzObject
{
- internal MusicBrainzEntity(string mbid, string parameters)
- : base(mbid, parameters)
+ internal MusicBrainzEntity (string mbid, string parameters) : base (mbid, parameters)
{
}
- internal MusicBrainzEntity(XmlReader reader, bool all_rels_loaded)
- : base(reader, all_rels_loaded)
+ internal MusicBrainzEntity (XmlReader reader, bool all_rels_loaded) : base (reader, all_rels_loaded)
{
}
- protected override void HandleCreateInc(StringBuilder builder)
+ protected override void HandleCreateInc (StringBuilder builder)
{
- if(aliases == null)
- AppendIncParameters(builder, "aliases");
- base.HandleCreateInc(builder);
+ if (aliases == null) AppendIncParameters (builder, "aliases");
+ base.HandleCreateInc (builder);
}
- protected void HandleLoadMissingData(MusicBrainzEntity entity)
+ protected void HandleLoadMissingData (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;
- base.HandleLoadMissingData(entity);
+ if (aliases == null) aliases = entity.Aliases;
+ base.HandleLoadMissingData (entity);
}
- protected override bool HandleXml(XmlReader reader)
+ protected override bool HandleXml (XmlReader reader)
{
bool result = true;
- switch(reader.Name) {
+ switch (reader.Name) {
case "name":
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- name = reader.ReadContentAsString();
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text) name = reader.ReadContentAsString ();
break;
case "sort-name":
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- sort_name = reader.ReadContentAsString();
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text) sort_name = reader.ReadContentAsString ();
break;
case "disambiguation":
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- disambiguation = reader.ReadContentAsString();
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text) disambiguation = reader.ReadContentAsString ();
break;
case "life-span":
- begin_date = reader["begin"];
- end_date = reader["end"];
+ begin_date = reader ["begin"];
+ end_date = reader ["end"];
break;
case "alias-list":
- if(reader.ReadToDescendant("alias")) {
- aliases = new List<string>();
+ if (reader.ReadToDescendant ("alias")) {
+ aliases = new List<string> ();
do {
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- aliases.Add(reader.ReadContentAsString());
- } while(reader.ReadToNextSibling("alias"));
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text)
+ aliases.Add (reader.ReadContentAsString ());
+ } while (reader.ReadToNextSibling ("alias"));
}
break;
default:
@@ -88,54 +81,48 @@
# region Properties
string name;
- public virtual string Name
- {
- get { return GetPropertyOrNull<string>(ref name); }
+ public virtual string Name {
+ get { return GetPropertyOrNull<string> (ref name); }
}
string sort_name;
[Queryable]
- public virtual string SortName
- {
- get { return GetPropertyOrNull<string>(ref sort_name); }
+ public virtual string SortName {
+ get { return GetPropertyOrNull<string> (ref sort_name); }
}
string disambiguation;
- [Queryable("comment")]
- public virtual string Disambiguation
- {
- get { return GetPropertyOrNull<string>(ref disambiguation); }
+ [Queryable ("comment")]
+ public virtual string Disambiguation {
+ get { return GetPropertyOrNull<string> (ref disambiguation); }
}
string begin_date;
- [Queryable("begin")]
- public virtual string BeginDate
- {
- get { return GetPropertyOrNull<string>(ref begin_date); }
+ [Queryable ("begin")]
+ public virtual string BeginDate {
+ get { return GetPropertyOrNull<string> (ref begin_date); }
}
string end_date;
- [Queryable("end")]
- public virtual string EndDate
- {
- get { return GetPropertyOrNull<string>(ref end_date); }
+ [Queryable ("end")]
+ public virtual string EndDate {
+ get { return GetPropertyOrNull<string> (ref end_date); }
}
List<string> aliases;
- [QueryableMember("Contains", "alias")]
- public virtual List<string> Aliases
- {
- get { return GetPropertyOrNew<List<string>>(ref aliases); }
+ [QueryableMember ("Contains", "alias")]
+ public virtual List<string> Aliases {
+ get { return GetPropertyOrNew<List<string>> (ref aliases); }
}
#endregion
- protected static string CreateNameParameter(string name)
+ protected static string CreateNameParameter (string name)
{
- return "&name=" + Utilities.PercentEncode(name);
+ return "&name=" + Utilities.PercentEncode (name);
}
- public override string ToString()
+ public override string ToString ()
{
return name;
}
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 Thu Feb 21 22:07:32 2008
@@ -12,24 +12,24 @@
{
public sealed class MusicBrainzInvalidParameterException : Exception
{
- public MusicBrainzInvalidParameterException()
- : base("One of the parameters is invalid. The MBID may be invalid, or you may be using an illegal parameter for this resource type.")
+ public MusicBrainzInvalidParameterException ()
+ : base ("One of the parameters is invalid. The MBID may be invalid, or you may be using an illegal parameter for this resource type.")
{
}
}
public sealed class MusicBrainzNotFoundException : Exception
{
- public MusicBrainzNotFoundException()
- : base("Specified resource was not found. Perhaps it was merged or deleted.")
+ public MusicBrainzNotFoundException ()
+ : base ("Specified resource was not found. Perhaps it was merged or deleted.")
{
}
}
public sealed class MusicBrainzUnauthorizedException : Exception
{
- public MusicBrainzUnauthorizedException()
- : base("The client is not authorized to perform this action. You may not have authenticated, or the username or password may be incorrect.")
+ public MusicBrainzUnauthorizedException ()
+ : base ("The client is not authorized to perform this action. You may not have authenticated, or the username or password may be incorrect.")
{
}
}
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 Thu Feb 21 22:07:32 2008
@@ -15,73 +15,71 @@
{
public abstract class ItemQueryParameters
{
- string title;
- public string Title
+ internal ItemQueryParameters ()
{
+ }
+
+ string title;
+ public string Title {
get { return title; }
set { title = value; }
}
string artist;
- public string Artist
- {
+ public string Artist {
get { return artist; }
set { artist = value; }
}
string artist_id;
- public string ArtistId
- {
+ public string ArtistId {
get { return artist_id; }
set { artist_id = value; }
}
ReleaseType? release_type;
- public ReleaseType? ReleaseType
- {
+ public ReleaseType? ReleaseType {
get { return release_type; }
set { release_type = value; }
}
ReleaseStatus? release_status;
- public ReleaseStatus? ReleaseStatus
- {
+ public ReleaseStatus? ReleaseStatus {
get { return release_status; }
set { release_status = value; }
}
int? count;
- public int? TrackCount
- {
+ public int? TrackCount {
get { return count; }
set { count = value; }
}
- protected void AppendBaseToBuilder(StringBuilder builder)
+ protected void AppendBaseToBuilder (StringBuilder builder)
{
- if(title != null) {
- builder.Append("&title=");
- Utilities.PercentEncode(builder, title);
- }
- if(artist != null) {
- builder.Append("&artist=");
- Utilities.PercentEncode(builder, artist);
- }
- if(artist_id != null) {
- builder.Append("&artistid=");
- builder.Append(artist_id);
- }
- if(release_type != null) {
- builder.Append("&releasetypes=");
- builder.Append(Utilities.EnumToString(release_type.Value));
- }
- if(release_status != null) {
- builder.Append(release_type != null ? "+" : "&releasetypes=");
- builder.Append(release_status);
- }
- if(count != null) {
- builder.Append("&count=");
- builder.Append(count.Value);
+ if (title != null) {
+ builder.Append ("&title=");
+ Utilities.PercentEncode (builder, title);
+ }
+ if (artist != null) {
+ builder.Append ("&artist=");
+ Utilities.PercentEncode (builder, artist);
+ }
+ if (artist_id != null) {
+ builder.Append ("&artistid=");
+ builder.Append (artist_id);
+ }
+ if (release_type != null) {
+ builder.Append ("&releasetypes=");
+ builder.Append (Utilities.EnumToString (release_type.Value));
+ }
+ if (release_status != null) {
+ builder.Append (release_type != null ? "+" : "&releasetypes=");
+ builder.Append (release_status);
+ }
+ if (count != null) {
+ builder.Append ("&count=");
+ builder.Append (count.Value);
}
}
}
@@ -89,42 +87,37 @@
// The item-like product of an artist, such as a track or a release.
public abstract class MusicBrainzItem : MusicBrainzObject
{
- internal MusicBrainzItem(string mbid, string parameters)
- : base(mbid, parameters)
+ internal MusicBrainzItem (string mbid, string parameters) : base (mbid, parameters)
{
}
- internal MusicBrainzItem(XmlReader reader, bool all_rels_loaded)
- : base(reader, all_rels_loaded)
+ internal MusicBrainzItem (XmlReader reader, bool all_rels_loaded) : base (reader, all_rels_loaded)
{
}
- protected override void HandleCreateInc(StringBuilder builder)
+ protected override void HandleCreateInc (StringBuilder builder)
{
- if(artist == null)
- AppendIncParameters(builder, "artist");
- base.HandleCreateInc(builder);
+ if (artist == null) AppendIncParameters(builder, "artist");
+ base.HandleCreateInc (builder);
}
- protected void HandleLoadMissingData(MusicBrainzItem item)
+ protected void HandleLoadMissingData (MusicBrainzItem item)
{
title = item.Title;
- if(artist == null)
- artist = item.Artist;
- base.HandleLoadMissingData(item);
+ if(artist == null) artist = item.Artist;
+ base.HandleLoadMissingData (item);
}
- protected override bool HandleXml(XmlReader reader)
+ protected override bool HandleXml (XmlReader reader)
{
bool result = true;
- switch(reader.Name) {
+ switch (reader.Name) {
case "title":
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- title = reader.ReadContentAsString();
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text) title = reader.ReadContentAsString ();
break;
case "artist":
- artist = new Artist(reader.ReadSubtree());
+ artist = new Artist (reader.ReadSubtree ());
break;
default:
result = false;
@@ -134,20 +127,17 @@
}
string title;
- public virtual string Title
- {
- get { return GetPropertyOrNull<string>(ref title); }
+ public virtual string Title {
+ get { return GetPropertyOrNull<string> (ref title); }
}
Artist artist;
- [Queryable("artist")]
- public virtual Artist Artist
- {
- get { return GetPropertyOrNull<Artist>(ref artist); }
+ [Queryable ("artist")]
+ public virtual Artist Artist {
+ get { return GetPropertyOrNull<Artist> (ref artist); }
}
- public override string ToString()
- {
+ 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 Thu Feb 21 22:07:32 2008
@@ -18,55 +18,53 @@
namespace MusicBrainz
{
- internal delegate void XmlProcessingDelegate(XmlReader reader);
- public delegate void XmlRequestHandler(string url, bool from_cache);
+ public delegate void XmlRequestHandler (string url, bool from_cache);
+ internal delegate void XmlProcessingDelegate (XmlReader reader);
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 TimeSpan min_interval = new TimeSpan (0, 0, 1); // 1 second
static DateTime last_accessed;
- static readonly object server_mutex = new object();
+ static readonly object server_mutex = new object ();
bool all_data_loaded;
- protected bool AllDataLoaded
- {
+ protected bool AllDataLoaded {
get { return all_data_loaded; }
}
bool all_rels_loaded;
- protected bool AllRelsLoaded
- {
+ protected bool AllRelsLoaded {
get { return all_rels_loaded; }
set { all_rels_loaded = value; }
}
protected abstract string UrlExtension { get; }
- internal MusicBrainzObject(string mbid, string parameters)
+ internal MusicBrainzObject (string mbid, string parameters)
{
all_data_loaded = true;
- CreateFromMbid(mbid, parameters ?? CreateInc());
+ CreateFromMbid (mbid, parameters ?? CreateInc ());
}
- internal MusicBrainzObject(XmlReader reader, bool all_rels_loaded)
+ internal MusicBrainzObject (XmlReader reader, bool all_rels_loaded)
{
this.all_rels_loaded = all_rels_loaded;
- CreateFromXml(reader);
+ CreateFromXml (reader);
}
- protected string CreateInc()
+ protected string CreateInc ()
{
- StringBuilder builder = new StringBuilder();
- HandleCreateInc(builder);
- return builder.ToString();
+ StringBuilder builder = new StringBuilder ();
+ HandleCreateInc (builder);
+ return builder.ToString ();
}
- protected virtual void HandleCreateInc(StringBuilder builder)
+ protected virtual void HandleCreateInc (StringBuilder builder)
{
- if(!all_rels_loaded)
- AppendIncParameters(builder,
+ if (!all_rels_loaded)
+ AppendIncParameters (builder,
"artist-rels",
"release-rels",
"track-rels",
@@ -74,96 +72,94 @@
"url-rels");
}
- protected void AppendIncParameters(StringBuilder builder, params string[] parameters)
+ protected void AppendIncParameters (StringBuilder builder, params string [] parameters)
{
- foreach(string parameter in parameters) {
- builder.Append(builder.Length == 0 ? "&inc=" : "+");
- builder.Append(parameter);
+ foreach (string parameter in parameters) {
+ builder.Append (builder.Length == 0 ? "&inc=" : "+");
+ builder.Append (parameter);
}
}
- void CreateFromMbid(string mbid, string parameters)
+ void CreateFromMbid (string mbid, string parameters)
{
- XmlProcessingClosure(
- CreateUrl(UrlExtension, mbid, parameters),
- delegate(XmlReader reader) {
- reader.ReadToFollowing("metadata");
- reader.Read();
- CreateFromXml(reader.ReadSubtree());
- reader.Close();
+ XmlProcessingClosure (
+ CreateUrl (UrlExtension, mbid, parameters),
+ delegate (XmlReader reader) {
+ reader.ReadToFollowing ("metadata");
+ reader.Read ();
+ CreateFromXml (reader.ReadSubtree ());
+ reader.Close ();
}
);
}
- protected abstract bool HandleAttributes(XmlReader reader);
- protected abstract bool HandleXml(XmlReader reader);
- void CreateFromXml(XmlReader reader)
- {
- reader.Read();
- mbid = reader["id"];
- byte.TryParse(reader["ext:score"], out score);
- HandleAttributes(reader);
- while(reader.Read() && reader.NodeType != XmlNodeType.EndElement) {
- if(reader.Name == "relation-list") {
+ protected abstract bool HandleAttributes (XmlReader reader);
+ protected abstract bool HandleXml (XmlReader reader);
+ void CreateFromXml (XmlReader reader)
+ {
+ reader.Read ();
+ mbid = reader ["id"];
+ byte.TryParse (reader ["ext:score"], out score);
+ HandleAttributes (reader);
+ while (reader.Read () && reader.NodeType != XmlNodeType.EndElement) {
+ if (reader.Name == "relation-list") {
all_rels_loaded = true;
- switch(reader["target-type"]) {
+ switch (reader ["target-type"]) {
case "Artist":
- artist_rels = new List<Relation<Artist>>();
- CreateRelation<Artist>(reader.ReadSubtree(), artist_rels);
+ artist_rels = new List<Relation<Artist>> ();
+ CreateRelation<Artist> (reader.ReadSubtree (), artist_rels);
break;
case "Release":
- release_rels = new List<Relation<Release>>();
- CreateRelation<Release>(reader.ReadSubtree(), release_rels);
+ release_rels = new List<Relation<Release>> ();
+ CreateRelation<Release> (reader.ReadSubtree (), release_rels);
break;
case "Track":
- track_rels = new List<Relation<Track>>();
- CreateRelation<Track>(reader.ReadSubtree(), track_rels);
+ track_rels = new List<Relation<Track>> ();
+ CreateRelation<Track> (reader.ReadSubtree (), track_rels);
break;
case "Label":
- label_rels = new List<Relation<Label>>();
- CreateRelation<Label>(reader.ReadSubtree(), label_rels);
+ label_rels = new List<Relation<Label>> ();
+ CreateRelation<Label> (reader.ReadSubtree (), label_rels);
break;
case "Url":
- if(!reader.ReadToDescendant("relation"))
- break;
- url_rels = new List<UrlRelation>();
+ if (!reader.ReadToDescendant ("relation")) break;
+ url_rels = new List<UrlRelation> ();
do {
RelationDirection direction = RelationDirection.Forward;
- string direction_string = reader["direction"];
- if(direction_string != null && direction_string == "backward")
+ string direction_string = reader ["direction"];
+ if (direction_string != null && direction_string == "backward")
direction = RelationDirection.Backward;
- string attributes_string = reader["attributes"];
- string[] attributes = attributes_string == null
- ? null
- : attributes_string.Split(' ');
- url_rels.Add(new UrlRelation(
- reader["type"],
- reader["target"],
+ string attributes_string = reader ["attributes"];
+ string [] attributes = attributes_string == null
+ ? null : attributes_string.Split (' ');
+ url_rels.Add (new UrlRelation (
+ reader ["type"],
+ reader ["target"],
direction,
- reader["begin"],
- reader["end"],
+ reader ["begin"],
+ reader ["end"],
attributes));
- } while(reader.ReadToNextSibling("relation"));
+ } while (reader.ReadToNextSibling ("relation"));
break;
}
} else
- HandleXml(reader.ReadSubtree());
+ HandleXml (reader.ReadSubtree ());
}
- reader.Close();
+ reader.Close ();
}
- protected void LoadMissingData()
+ protected void LoadMissingData ()
{
- if(!all_data_loaded) {
- HandleLoadMissingData();
+ if (!all_data_loaded) {
+ HandleLoadMissingData ();
all_data_loaded = true;
}
}
- protected abstract void HandleLoadMissingData();
- protected void HandleLoadMissingData(MusicBrainzObject obj)
+ protected abstract void HandleLoadMissingData ();
+ protected void HandleLoadMissingData (MusicBrainzObject obj)
{
- if(!all_rels_loaded) {
+ if (!all_rels_loaded) {
artist_rels = obj.ArtistRelations;
release_rels = obj.ReleaseRelations;
track_rels = obj.TrackRelations;
@@ -174,198 +170,184 @@
#region Properties
- protected T GetPropertyOrNull<T>(ref T field_reference) where T : class
+ protected T GetPropertyOrNull<T> (ref T field_reference) where T : class
{
- if(field_reference == null)
- LoadMissingData();
+ if (field_reference == null) LoadMissingData ();
return field_reference;
}
- protected T GetPropertyOrDefault<T>(ref T? field_reference, T default_value) where T : struct
+ protected T GetPropertyOrDefault<T> (ref T? field_reference, T default_value) where T : struct
{
- if(field_reference == null)
- LoadMissingData();
+ if (field_reference == null) LoadMissingData ();
return field_reference ?? default_value;
}
- protected T GetPropertyOrNew<T>(ref T field_reference) where T : class, new()
+ protected T GetPropertyOrNew<T> (ref T field_reference) where T : class, new ()
{
- return GetPropertyOrNew<T>(ref field_reference, true);
+ return GetPropertyOrNew<T> (ref field_reference, true);
}
- protected T GetPropertyOrNew<T>(ref T field_reference, bool condition) where T : class, new()
+ protected T GetPropertyOrNew<T> (ref T field_reference, bool condition) where T : class, new ()
{
- if(field_reference == null && condition)
- LoadMissingData();
- return field_reference ?? new T();
+ if (field_reference == null && condition) LoadMissingData ();
+ return field_reference ?? new T ();
}
string mbid;
- public virtual string MBID
- {
+ public virtual string MBID {
get { return mbid; }
}
byte score;
- public virtual byte Score
- {
+ public virtual byte Score {
get { return score; }
}
List<Relation<Artist>> artist_rels;
- public virtual List<Relation<Artist>> ArtistRelations
- {
- get { return GetPropertyOrNew<List<Relation<Artist>>>(ref artist_rels, !all_rels_loaded); }
+ public virtual List<Relation<Artist>> ArtistRelations {
+ get { return GetPropertyOrNew<List<Relation<Artist>>> (ref artist_rels, !all_rels_loaded); }
}
List<Relation<Release>> release_rels;
- public virtual List<Relation<Release>> ReleaseRelations
- {
- get { return GetPropertyOrNew<List<Relation<Release>>>(ref release_rels, !all_rels_loaded); }
+ public virtual List<Relation<Release>> ReleaseRelations {
+ get { return GetPropertyOrNew<List<Relation<Release>>> (ref release_rels, !all_rels_loaded); }
}
List<Relation<Track>> track_rels;
- public virtual List<Relation<Track>> TrackRelations
- {
- get { return GetPropertyOrNew<List<Relation<Track>>>(ref track_rels, !all_rels_loaded); }
+ public virtual List<Relation<Track>> TrackRelations {
+ get { return GetPropertyOrNew<List<Relation<Track>>> (ref track_rels, !all_rels_loaded); }
}
List<Relation<Label>> label_rels;
- public virtual List<Relation<Label>> LabelRelations
- {
- get { return GetPropertyOrNew<List<Relation<Label>>>(ref label_rels, !all_rels_loaded); }
+ public virtual List<Relation<Label>> LabelRelations {
+ get { return GetPropertyOrNew<List<Relation<Label>>> (ref label_rels, !all_rels_loaded); }
}
List<UrlRelation> url_rels;
- public virtual List<UrlRelation> UrlRelations
- {
- get { return GetPropertyOrNew<List<UrlRelation>>(ref url_rels, !all_rels_loaded); }
+ public virtual List<UrlRelation> UrlRelations {
+ get { return GetPropertyOrNew<List<UrlRelation>> (ref url_rels, !all_rels_loaded); }
}
- public override bool Equals(object obj)
+ 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.MBID == MBID;
}
- public override int GetHashCode()
+ public override int GetHashCode ()
{
- return (GetType().Name + MBID).GetHashCode();
+ return (GetType ().Name + MBID).GetHashCode ();
}
#endregion
#region Static Methods
- static void CreateRelation<T>(XmlReader reader, List<Relation<T>> relations) where T : MusicBrainzObject
+ static void CreateRelation<T> (XmlReader reader, List<Relation<T>> relations) where T : MusicBrainzObject
{
- while(reader.ReadToFollowing("relation")) {
- string type = reader["type"];
+ while (reader.ReadToFollowing ("relation")) {
+ string type = reader ["type"];
RelationDirection direction = RelationDirection.Forward;
- string direction_string = reader["direction"];
- if(direction_string != null && direction_string == "backward")
+ string direction_string = reader ["direction"];
+ if (direction_string != null && direction_string == "backward")
direction = RelationDirection.Backward;
- string begin = reader["begin"];
- string end = reader["end"];
- string attributes_string = reader["attributes"];
+ string begin = reader ["begin"];
+ string end = reader ["end"];
+ string attributes_string = reader ["attributes"];
string[] attributes = attributes_string == null
- ? null
- : attributes_string.Split(' ');
+ ? null : attributes_string.Split (' ');
- reader.Read();
- relations.Add(new Relation<T>(
+ reader.Read ();
+ relations.Add (new Relation<T>(
type,
- ConstructMusicBrainzObjectFromXml<T>(reader.ReadSubtree()),
+ ConstructMusicBrainzObjectFromXml<T> (reader.ReadSubtree ()),
direction,
begin,
end,
attributes));
}
- reader.Close();
+ reader.Close ();
}
- static string CreateUrl(string url_extension, int limit, int offset, string parameters)
+ static string CreateUrl (string url_extension, int limit, int offset, string parameters)
{
- StringBuilder builder = new StringBuilder();
- if(limit != 25) {
- builder.Append("&limit=");
- builder.Append(limit);
+ StringBuilder builder = new StringBuilder ();
+ if (limit != 25) {
+ builder.Append ("&limit=");
+ builder.Append (limit);
}
- if(offset != 0) {
- builder.Append("&offset=");
- builder.Append(offset);
+ if (offset != 0) {
+ builder.Append ("&offset=");
+ builder.Append (offset);
}
- builder.Append(parameters);
- return CreateUrl(url_extension, string.Empty, builder.ToString());
+ builder.Append (parameters);
+ return CreateUrl (url_extension, string.Empty, builder.ToString ());
}
- static string CreateUrl(string url_extension, string mbid, string parameters)
+ static string CreateUrl (string url_extension, string mbid, string parameters)
{
- StringBuilder builder = new StringBuilder(ProviderUrl.Length + mbid.Length + parameters.Length + 9);
- builder.Append(ProviderUrl);
- builder.Append(url_extension);
- builder.Append('/');
- builder.Append(mbid);
- builder.Append("?type=xml");
- builder.Append(parameters);
- return builder.ToString();
+ StringBuilder builder = new StringBuilder (ProviderUrl.Length + mbid.Length + parameters.Length + 9);
+ builder.Append (ProviderUrl);
+ builder.Append (url_extension);
+ builder.Append ('/');
+ builder.Append (mbid);
+ builder.Append ("?type=xml");
+ builder.Append (parameters);
+ return builder.ToString ();
}
public static RequestCachePolicy CachePolicy;
public static event XmlRequestHandler XmlRequest;
- static void XmlProcessingClosure(string url, XmlProcessingDelegate code)
+ static void XmlProcessingClosure (string url, XmlProcessingDelegate code)
{
- Monitor.Enter(server_mutex);
+ Monitor.Enter (server_mutex);
// Don't access the MB server twice within a second
- TimeSpan time = DateTime.Now.Subtract(last_accessed);
- if(min_interval.CompareTo(time) > 0)
- Thread.Sleep(min_interval.Subtract(time).Milliseconds);
+ TimeSpan time = DateTime.Now.Subtract (last_accessed);
+ if(min_interval.CompareTo (time) > 0)
+ Thread.Sleep (min_interval.Subtract (time).Milliseconds);
- HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
+ HttpWebRequest request = WebRequest.Create (url) as HttpWebRequest;
bool cache_implemented = false;
try {
request.CachePolicy = CachePolicy;
cache_implemented = true;
- } catch(NotImplementedException) {
+ } catch (NotImplementedException) {
}
HttpWebResponse response = null;
try {
- response = request.GetResponse() as HttpWebResponse;
- } catch(WebException e) {
+ response = request.GetResponse () as HttpWebResponse;
+ } catch (WebException e) {
response = (HttpWebResponse)e.Response;
}
- if(response == null)
- throw new MusicBrainzNotFoundException();
+ if (response == null) throw new MusicBrainzNotFoundException ();
- switch(response.StatusCode) {
+ switch (response.StatusCode) {
case HttpStatusCode.BadRequest:
- Monitor.Exit(server_mutex);
- throw new MusicBrainzInvalidParameterException();
+ Monitor.Exit (server_mutex);
+ throw new MusicBrainzInvalidParameterException ();
case HttpStatusCode.Unauthorized:
- Monitor.Exit(server_mutex);
- throw new MusicBrainzUnauthorizedException();
+ Monitor.Exit (server_mutex);
+ throw new MusicBrainzUnauthorizedException ();
case HttpStatusCode.NotFound:
- Monitor.Exit(server_mutex);
- throw new MusicBrainzNotFoundException();
+ Monitor.Exit (server_mutex);
+ throw new MusicBrainzNotFoundException ();
}
bool from_cache = cache_implemented && response.IsFromCache;
- if(XmlRequest != null)
- XmlRequest(url, from_cache);
+ if (XmlRequest != null) XmlRequest (url, from_cache);
- if(from_cache)
- Monitor.Exit(server_mutex);
+ if (from_cache) Monitor.Exit (server_mutex);
// Should we read the stream into a memory stream and run the XmlReader off of that?
- code(new XmlTextReader(response.GetResponseStream()));
- response.Close();
+ code (new XmlTextReader (response.GetResponseStream ()));
+ response.Close ();
- if(!from_cache) {
+ if (!from_cache) {
last_accessed = DateTime.Now;
- Monitor.Exit(server_mutex);
+ Monitor.Exit (server_mutex);
}
}
@@ -373,43 +355,42 @@
#region Query
- protected static byte QueryLimit
- {
+ protected static byte QueryLimit {
get { return 100; }
}
- protected static string CreateLuceneParameter(string query)
+ protected static string CreateLuceneParameter (string query)
{
- return "&query=" + Utilities.PercentEncode(query);
+ return "&query=" + Utilities.PercentEncode (query);
}
- internal static List<T> Query<T>(string url_extension, byte limit, int offset, string parameters, out int? count) where T : MusicBrainzObject
+ internal static List<T> Query<T> (string url_extension, byte limit, int offset, string parameters, out int? count) where T : MusicBrainzObject
{
int count_value = 0;
- List<T> results = new List<T>();
- XmlProcessingClosure(
- CreateUrl(url_extension, limit, offset, parameters),
- delegate(XmlReader reader) {
- reader.ReadToFollowing("metadata");
- reader.Read();
- int.TryParse(reader["count"], out count_value);
- while(reader.Read() && reader.NodeType == XmlNodeType.Element)
- results.Add(ConstructMusicBrainzObjectFromXml<T>(reader.ReadSubtree()));
- reader.Close();
+ List<T> results = new List<T> ();
+ XmlProcessingClosure (
+ CreateUrl (url_extension, limit, offset, parameters),
+ delegate (XmlReader reader) {
+ reader.ReadToFollowing ("metadata");
+ reader.Read ();
+ int.TryParse (reader ["count"], out count_value);
+ while (reader.Read () && reader.NodeType == XmlNodeType.Element)
+ results.Add (ConstructMusicBrainzObjectFromXml<T> (reader.ReadSubtree ()));
+ reader.Close ();
}
);
count = count_value == 0 ? results.Count : count_value;
return results;
}
- static T ConstructMusicBrainzObjectFromXml<T>(XmlReader reader) where T : MusicBrainzObject
+ static T ConstructMusicBrainzObjectFromXml<T> (XmlReader reader) where T : MusicBrainzObject
{
- ConstructorInfo constructor = typeof(T).GetConstructor(
+ ConstructorInfo constructor = typeof (T).GetConstructor (
BindingFlags.NonPublic | BindingFlags.Instance,
null,
- new Type[] { typeof(XmlReader) },
+ new Type [] { typeof (XmlReader) },
null);
- return (T)constructor.Invoke(new object [] {reader});
+ return (T)constructor.Invoke (new object [] {reader});
}
#endregion
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 Thu Feb 21 22:07:32 2008
@@ -7,6 +7,7 @@
****************************************************************************/
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Text;
@@ -18,7 +19,7 @@
string url_extension;
byte limit;
- internal Query(string url_extension, byte limit, string parameters)
+ internal Query (string url_extension, byte limit, string parameters)
{
this.url_extension = url_extension;
this.limit = limit;
@@ -26,136 +27,123 @@
}
List<T> results;
- List<T> ResultsWindow
- {
+ List<T> ResultsWindow {
get {
- if(results == null)
- results = MusicBrainzObject.Query<T>(url_extension, limit, offset, parameters, out count);
+ if (results == null)
+ results = MusicBrainzObject.Query<T> (url_extension, limit, offset, parameters, out count);
return results;
}
}
int offset;
- Dictionary<int, WeakReference> weak_references = new Dictionary<int, WeakReference>();
- int Offset
- {
+ Dictionary<int, WeakReference> weak_references = new Dictionary<int, WeakReference> ();
+ int Offset {
get { return offset; }
set {
- if(value == offset)
- return;
+ if (value == offset) return;
// We WeakReference the results from previous offsets just in case.
- if(results != null)
- if(!weak_references.ContainsKey(offset))
- weak_references.Add(offset, new WeakReference(results));
- else
- weak_references[offset].Target = results;
+ if (results != null)
+ if (!weak_references.ContainsKey (offset)) weak_references.Add (offset, new WeakReference (results));
+ else weak_references [offset].Target = results;
results = null;
offset = value;
- if(weak_references.ContainsKey(offset)) {
- WeakReference weak_reference = weak_references[offset];
- if(weak_reference.IsAlive)
- results = weak_reference.Target as List<T>;
+ if (weak_references.ContainsKey (offset)) {
+ WeakReference weak_reference = weak_references [offset];
+ if (weak_reference.IsAlive) results = weak_reference.Target as List<T>;
}
}
}
int? count;
- public int Count
- {
+ public int Count {
get {
- if(count == null && ResultsWindow == null)
- { } // just accessing ResultsWindow will give count a value
+ if(count == null && ResultsWindow == null) { } // just accessing ResultsWindow will give count a value
return count.Value;
}
}
- public T this[int i]
- {
+ public T this [int i] {
get {
- if(i < 0 || i >= Count)
- throw new IndexOutOfRangeException();
- if(i <= offset || i >= offset + limit)
- Offset = i;
- return ResultsWindow[i - offset];
+ if (i < 0 || i >= Count) throw new IndexOutOfRangeException ();
+ if (i <= offset || i >= offset + limit) Offset = i;
+ return ResultsWindow [i - offset];
}
}
- public List<T> ToList()
+ public List<T> ToList ()
{
- return ToList(0);
+ return ToList (0);
}
- public List<T> ToList(int score_threshold)
+ public List<T> ToList (int score_threshold)
{
- List<T> list = new List<T>(score_threshold == 0 ? Count : 0);
- foreach(T result in Best(score_threshold))
- list.Add(result);
+ List<T> list = new List<T> (score_threshold == 0 ? Count : 0);
+ foreach (T result in Best(score_threshold)) list.Add (result);
return list;
}
- public T[] ToArray()
+ public T [] ToArray ()
{
- T[] array = new T[Count];
- for(int i = 0; i < Count; i++)
- array[i] = this[i];
+ T [] array = new T [Count];
+ for(int i = 0; i < Count; i++) array [i] = this [i];
return array;
}
- public IEnumerator<T> GetEnumerator()
+ public IEnumerator<T> GetEnumerator ()
{
- for(int i = 0; i < Count; i++)
- yield return this[i];
+ for (int i = 0; i < Count; i++)
+ yield return this [i];
}
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+
+ IEnumerator IEnumerable.GetEnumerator ()
{
- return GetEnumerator();
+ return GetEnumerator ();
}
- public IEnumerable<T> Best()
+ public IEnumerable<T> Best ()
{
- return Best(100);
+ return Best (100);
}
- public IEnumerable<T> Best(int score_threshold)
+ public IEnumerable<T> Best (int score_threshold)
{
- foreach(T result in this) {
- if(result.Score < score_threshold)
- yield break;
+ foreach (T result in this) {
+ if (result.Score < score_threshold) yield break;
yield return result;
}
}
- public static implicit operator T(Query<T> query)
+ public static implicit operator T (Query<T> query)
{
byte limit = query.limit;
query.limit = 1;
- T result = query.Count > 0 ? query[0] : null;
+ T result = query.Count > 0 ? query [0] : null;
query.limit = limit;
return result;
}
}
- [AttributeUsage(AttributeTargets.Property)]
+ [AttributeUsage (AttributeTargets.Property)]
internal sealed class QueryableAttribute : Attribute
{
public readonly string Name;
- public QueryableAttribute()
+ public QueryableAttribute ()
{
}
- public QueryableAttribute(string name)
+ public QueryableAttribute (string name)
{
Name = name;
}
}
- [AttributeUsage(AttributeTargets.Property)]
+ [AttributeUsage (AttributeTargets.Property)]
internal sealed class QueryableMemberAttribute : Attribute
{
public readonly string Name;
public readonly string Member;
- public QueryableMemberAttribute(string member, string name)
+ public QueryableMemberAttribute (string member, string name)
{
Member = member;
Name = 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 Thu Feb 21 22:07:32 2008
@@ -26,7 +26,7 @@
string begin;
string end;
- internal RelationPrimative(string type, T target, RelationDirection direction,
+ internal RelationPrimative (string type, T target, RelationDirection direction,
string begin, string end, string[] attributes)
{
this.type = type;
@@ -37,50 +37,53 @@
this.attributes = attributes;
}
- public T Target
- {
+ public T Target {
get { return target; }
}
- public string Type
- {
+ public string Type {
get { return type; }
}
- public string[] Attributes
- {
+ public string [] Attributes {
get { return attributes; }
}
- public RelationDirection Direction
- {
+ public RelationDirection Direction {
get { return direction; }
}
- public string BeginDate
- {
+ public string BeginDate {
get { return begin; }
}
- public string EndDate
- {
+
+ public string EndDate {
get { return end; }
}
}
public sealed class Relation<T> : RelationPrimative<T> where T : MusicBrainzObject
{
- internal Relation(string type, T target, RelationDirection direction,
- string begin, string end, string[] attributes)
- : base(type, target, direction, begin, end, attributes)
+ internal Relation (string type,
+ T target,
+ RelationDirection direction,
+ string begin,
+ string end,
+ string [] attributes)
+ : base (type, target, direction, begin, end, attributes)
{
}
}
public sealed class UrlRelation : RelationPrimative<string>
{
- internal UrlRelation(string type, string target, RelationDirection direction,
- string begin, string end, string[] attributes)
- : base(type, target, direction, begin, end, attributes)
+ internal UrlRelation(string type,
+ string target,
+ RelationDirection direction,
+ string begin,
+ string end,
+ string [] attributes)
+ : base (type, target, direction, begin, end, 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 Thu Feb 21 22:07:32 2008
@@ -42,6 +42,7 @@
public enum ReleaseFormat
{
+ None,
Cartridge,
Cassette,
CD,
@@ -51,7 +52,6 @@
DVD,
LaserDisc,
MiniDisc,
- None,
Other,
ReelToReel,
SACD,
@@ -63,140 +63,128 @@
public sealed class ReleaseQueryParameters : ItemQueryParameters
{
string disc_id;
- public string DiscID
- {
+ public string DiscID {
get { return disc_id; }
set { disc_id = value; }
}
string date;
- public string Date
- {
+ public string Date {
get { return date; }
set { date = value; }
}
string asin;
- public string Asin
- {
+ public string Asin {
get { return asin; }
set { asin = value; }
}
string language;
- public string Language
- {
+ public string Language {
get { return language; }
set { language = value; }
}
string script;
- public string Script
- {
+ public string Script {
get { return script; }
set { script = value; }
}
- public override string ToString()
+ public override string ToString ()
{
- StringBuilder builder = new StringBuilder();
- if(disc_id != null) {
- builder.Append("&discid=");
- builder.Append(disc_id);
+ StringBuilder builder = new StringBuilder ();
+ if (disc_id != null) {
+ builder.Append ("&discid=");
+ builder.Append (disc_id);
}
- if(date != null) {
- builder.Append("&date=");
- Utilities.PercentEncode(builder, date);
+ if (date != null) {
+ builder.Append ("&date=");
+ Utilities.PercentEncode (builder, date);
}
- if(asin != null) {
- builder.Append("&asin=");
- builder.Append(asin);
+ if (asin != null) {
+ builder.Append ("&asin=");
+ builder.Append (asin);
}
- if(language != null) {
- builder.Append("&lang=");
- builder.Append(language);
+ if (language != null) {
+ builder.Append ("&lang=");
+ builder.Append (language);
}
- if(script != null) {
- builder.Append("&script=");
- builder.Append(script);
+ if (script != null) {
+ builder.Append ("&script=");
+ builder.Append (script);
}
- AppendBaseToBuilder(builder);
- return builder.ToString();
+ AppendBaseToBuilder (builder);
+ return builder.ToString ();
}
}
public sealed class Release : MusicBrainzItem
{
const string EXTENSION = "release";
- protected override string UrlExtension
- {
+
+ protected override string UrlExtension {
get { return EXTENSION; }
}
- Release(string mbid)
- : base(mbid, null)
+ Release (string mbid) : base (mbid, null)
{
}
- Release(string mbid, string parameters)
- : base(mbid, parameters)
+ Release (string mbid, string parameters) : base (mbid, parameters)
{
}
- internal Release(XmlReader reader)
- : base(reader, false)
+ internal Release (XmlReader reader) : base(reader, false)
{
}
- protected override void HandleCreateInc(StringBuilder builder)
+ protected override void HandleCreateInc (StringBuilder builder)
{
- AppendIncParameters(builder, "release-events", "labels");
- if(discs == null)
- AppendIncParameters(builder, "discs");
- if(tracks == null) {
- AppendIncParameters(builder, "tracks", "track-level-rels");
+ AppendIncParameters (builder, "release-events", "labels");
+ if (discs == null) AppendIncParameters (builder, "discs");
+ if (tracks == null) {
+ AppendIncParameters (builder, "tracks", "track-level-rels");
AllRelsLoaded = false;
}
- base.HandleCreateInc(builder);
+ base.HandleCreateInc (builder);
}
- protected override void HandleLoadMissingData()
+ protected override void HandleLoadMissingData ()
{
- Release release = new Release(MBID, CreateInc());
+ Release release = new Release (MBID, 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;
- base.HandleLoadMissingData(release);
+ if (discs == null) discs = release.Discs;
+ if (tracks == null) tracks = release.Tracks;
+ base.HandleLoadMissingData (release);
}
- protected override bool HandleAttributes(XmlReader reader)
+ protected override bool HandleAttributes (XmlReader reader)
{
// How sure am I about getting the type and status in the "Type Status" format?
// MB really ought to specify these two things seperatly.
- string type_string = reader["type"];
- if(type_string != null) {
- foreach(string token in type_string.Split(' ')) {
- if(this.type == null) {
+ string type_string = reader ["type"];
+ if (type_string != null) {
+ foreach (string token in type_string.Split (' ')) {
+ if (this.type == null) {
bool found = false;
- foreach(ReleaseType type in Enum.GetValues(typeof(ReleaseType)) as ReleaseType[])
- if(type.ToString() == token) {
+ foreach (ReleaseType type in Enum.GetValues (typeof (ReleaseType)) as ReleaseType [])
+ if (type.ToString () == token) {
this.type = type;
found = true;
break;
}
- if(found)
- continue;
+ if (found) continue;
}
- foreach(ReleaseStatus status in Enum.GetValues(typeof(ReleaseStatus)) as ReleaseStatus[])
- if(status.ToString() == token) {
+ foreach (ReleaseStatus status in Enum.GetValues (typeof (ReleaseStatus)) as ReleaseStatus [])
+ if (status.ToString () == token) {
this.status = status;
break;
}
@@ -205,202 +193,177 @@
return this.type != null || this.status != null;
}
- protected override bool HandleXml(XmlReader reader)
+ protected override bool HandleXml (XmlReader reader)
{
- reader.Read();
- bool result = base.HandleXml(reader);
- if(!result) {
+ reader.Read ();
+ bool result = base.HandleXml (reader);
+ if (!result) {
result = true;
- switch(reader.Name) {
+ switch (reader.Name) {
case "text-representation":
- language = reader["language"];
- script = reader["script"];
+ language = reader ["language"];
+ script = reader ["script"];
break;
case "asin":
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- asin = reader.ReadContentAsString();
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text) asin = reader.ReadContentAsString ();
break;
case "disc-list": {
- if(reader.ReadToDescendant("disc")) {
- discs = new List<Disc>();
- do discs.Add(new Disc(reader.ReadSubtree()));
- while(reader.ReadToNextSibling("disc"));
+ if (reader.ReadToDescendant ("disc")) {
+ discs = new List<Disc> ();
+ do discs.Add (new Disc (reader.ReadSubtree ()));
+ while (reader.ReadToNextSibling ("disc"));
}
break;
}
case "release-event-list":
- if(!AllDataLoaded)
- reader.Skip(); // FIXME this is a workaround for Mono bug 334752
- if(reader.ReadToDescendant("event")) {
- events = new List<Event>();
- do events.Add(new Event(reader.ReadSubtree()));
- while(reader.ReadToNextSibling("event"));
+ if (!AllDataLoaded) reader.Skip(); // FIXME this is a workaround for Mono bug 334752
+ if (reader.ReadToDescendant ("event")) {
+ events = new List<Event> ();
+ do events.Add (new Event (reader.ReadSubtree ()));
+ while (reader.ReadToNextSibling ("event"));
}
break;
case "track-list": {
- string offset = reader["offset"];
- if(offset != null)
- track_number = int.Parse(offset) + 1;
- if(reader.ReadToDescendant("track")) {
- tracks = new List<Track>();
- do tracks.Add(new Track(reader.ReadSubtree(), AllDataLoaded));
- while(reader.ReadToNextSibling("track"));
+ string offset = reader ["offset"];
+ if (offset != null) track_number = int.Parse (offset) + 1;
+ if (reader.ReadToDescendant ("track")) {
+ tracks = new List<Track> ();
+ do tracks.Add (new Track (reader.ReadSubtree (), AllDataLoaded));
+ while (reader.ReadToNextSibling ("track"));
}
break;
}
default:
- reader.Skip(); // FIXME this is a workaround for Mono bug 334752
+ reader.Skip (); // FIXME this is a workaround for Mono bug 334752
result = false;
break;
}
}
- reader.Close();
+ reader.Close ();
return result;
}
#region Properties
- [Queryable("reid")]
- public override string MBID
- {
+ [Queryable ("reid")]
+ public override string MBID {
get { return base.MBID; }
}
- [Queryable("release")]
- public override string Title
- {
+ [Queryable ("release")]
+ public override string Title {
get { return base.Title; }
}
ReleaseType? type;
[Queryable]
- public ReleaseType Type
- {
- get { return GetPropertyOrDefault<ReleaseType>(ref type, ReleaseType.None); }
+ public ReleaseType Type {
+ get { return GetPropertyOrDefault<ReleaseType> (ref type, ReleaseType.None); }
}
ReleaseStatus? status;
[Queryable]
- public ReleaseStatus Status
- {
- get { return GetPropertyOrDefault<ReleaseStatus>(ref status, ReleaseStatus.None); }
+ public ReleaseStatus Status {
+ get { return GetPropertyOrDefault<ReleaseStatus> (ref status, ReleaseStatus.None); }
}
string language;
- public string Language
- {
- get { return GetPropertyOrNull<string>(ref language); }
+ public string Language {
+ get { return GetPropertyOrNull<string> (ref language); }
}
string script;
[Queryable]
- public string Script
- {
- get { return GetPropertyOrNull<string>(ref script); }
+ public string Script {
+ get { return GetPropertyOrNull<string> (ref script); }
}
string asin;
[Queryable]
- public string Asin
- {
- get { return GetPropertyOrNull<string>(ref asin); }
+ public string Asin {
+ get { return GetPropertyOrNull<string> (ref asin); }
}
List<Disc> discs;
[QueryableMember("Count", "discids")]
- public List<Disc> Discs
- {
- get { return GetPropertyOrNew<List<Disc>>(ref discs); }
+ public List<Disc> Discs {
+ get { return GetPropertyOrNew<List<Disc>> (ref discs); }
}
List<Event> events;
- public List<Event> Events
- {
- get { return GetPropertyOrNew<List<Event>>(ref events); }
+ public List<Event> Events {
+ get { return GetPropertyOrNew<List<Event>> (ref events); }
}
List<Track> tracks;
- [QueryableMember("Count", "tracks")]
- public List<Track> Tracks
- {
- get { return GetPropertyOrNew<List<Track>>(ref tracks); }
+ [QueryableMember ("Count", "tracks")]
+ public List<Track> Tracks {
+ get { return GetPropertyOrNew<List<Track>> (ref tracks); }
}
int? track_number;
- internal int TrackNumber
- {
+ internal int TrackNumber {
get { return track_number != null ? track_number.Value : -1; }
}
#endregion
- public static Release Get(string mbid)
+ public static Release Get (string mbid)
{
- if(mbid == null)
- throw new ArgumentNullException("mbid");
-
- return new Release(mbid);
+ if (mbid == null) throw new ArgumentNullException ("mbid");
+ return new Release (mbid);
}
#region Query
- public static Query<Release> Query(string title)
+ public static Query<Release> Query (string title)
{
- if(title == null)
- throw new ArgumentNullException("title");
+ if (title == null) throw new ArgumentNullException ("title");
- ReleaseQueryParameters parameters = new ReleaseQueryParameters();
+ ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
parameters.Title = title;
- return Query(parameters);
+ return Query (parameters);
}
- public static Query<Release> Query(string title, string artist)
+ public static Query<Release> Query (string title, string artist)
{
- if(title == null)
- throw new ArgumentNullException("title");
-
- if(artist == null)
- throw new ArgumentNullException("artist");
+ if (title == null) throw new ArgumentNullException ("title");
+ if (artist == null) throw new ArgumentNullException ("artist");
- ReleaseQueryParameters parameters = new ReleaseQueryParameters();
+ ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
parameters.Title = title;
parameters.Artist = artist;
- return Query(parameters);
+ return Query (parameters);
}
- public static Query<Release> Query(ReleaseQueryParameters parameters)
+ public static Query<Release> Query (ReleaseQueryParameters parameters)
{
- if(parameters == null)
- throw new ArgumentNullException("parameters");
-
- return new Query<Release>(EXTENSION, QueryLimit, parameters.ToString());
+ if (parameters == null) throw new ArgumentNullException ("parameters");
+ return new Query<Release> (EXTENSION, QueryLimit, parameters.ToString ());
}
public static Query<Release> QueryFromDevice(string device)
{
- if(device == null)
- throw new ArgumentNullException("device");
+ if (device == null) throw new ArgumentNullException ("device");
- ReleaseQueryParameters parameters = new ReleaseQueryParameters();
- parameters.DiscID = Disc.GetFromDevice(device).ID;
- return Query(parameters);
+ ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
+ parameters.DiscID = Disc.GetFromDevice (device).ID;
+ return Query (parameters);
}
- public static Query<Release> QueryLucene(string lucene_query)
+ public static Query<Release> QueryLucene (string luceneQuery)
{
- if(lucene_query == null)
- throw new ArgumentNullException("lucene_query");
-
- return new Query<Release>(EXTENSION, QueryLimit, CreateLuceneParameter(lucene_query));
+ if (luceneQuery == null) throw new ArgumentNullException ("luceneQuery");
+ return new Query<Release> (EXTENSION, QueryLimit, CreateLuceneParameter (luceneQuery));
}
#endregion
- public static implicit operator string(Release r)
+ public static implicit operator string (Release release)
{
- return r.ToString();
+ return release.ToString ();
}
}
}
\ No newline at end of file
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 Thu Feb 21 22:07:32 2008
@@ -16,277 +16,243 @@
public sealed class TrackQueryParameters : ItemQueryParameters
{
string release;
- public string Release
- {
+ public string Release {
get { return release; }
set { release = value; }
}
string release_id;
- public string ReleaseId
- {
+ public string ReleaseId {
get { return release_id; }
set { release_id = value; }
}
uint? duration;
- public uint? Duration
- {
+ public uint? Duration {
get { return duration; }
set { duration = value; }
}
int? track_number;
- public int? TrackNumber
- {
+ public int? TrackNumber {
get { return track_number; }
set { track_number = value; }
}
string puid;
- public string Puid
- {
+ public string Puid {
get { return puid; }
set { puid = value; }
}
- public override string ToString()
+ public override string ToString ()
{
- StringBuilder builder = new StringBuilder();
- if(release != null) {
- builder.Append("&release=");
- Utilities.PercentEncode(builder, release);
- }
- if(release_id != null) {
- builder.Append("&releaseid=");
- builder.Append(release_id);
+ StringBuilder builder = new StringBuilder ();
+ if (release != null) {
+ builder.Append ("&release=");
+ Utilities.PercentEncode (builder, release);
+ }
+ if (release_id != null) {
+ builder.Append ("&releaseid=");
+ builder.Append (release_id);
+ }
+ if (duration != null) {
+ builder.Append ("&duration=");
+ builder.Append (duration.Value);
+ }
+ if (track_number != null) {
+ builder.Append ("&tracknumber=");
+ builder.Append (track_number.Value);
+ }
+ if (puid != null) {
+ builder.Append ("&puid=");
+ builder.Append (puid);
}
- if(duration != null) {
- builder.Append("&duration=");
- builder.Append(duration.Value);
- }
- if(track_number != null) {
- builder.Append("&tracknumber=");
- builder.Append(track_number.Value);
- }
- if(puid != null) {
- builder.Append("&puid=");
- builder.Append(puid);
- }
- AppendBaseToBuilder(builder);
- return builder.ToString();
+ AppendBaseToBuilder (builder);
+ return builder.ToString ();
}
}
public sealed class Track : MusicBrainzItem
{
const string EXTENSION = "track";
- protected override string UrlExtension
- {
+
+ protected override string UrlExtension {
get { return EXTENSION; }
}
- Track(string mbid)
- : base(mbid, null)
+ Track (string mbid) : base (mbid, null)
{
}
- Track(string mbid, string parameters)
- : base(mbid, parameters)
+ Track (string mbid, string parameters) : base (mbid, parameters)
{
}
- internal Track(XmlReader reader)
- : base(reader, false)
+ internal Track (XmlReader reader) : base (reader, false)
{
}
- internal Track(XmlReader reader, bool all_rels_loaded)
- : base(reader, all_rels_loaded)
+ internal Track (XmlReader reader, bool all_rels_loaded) : base (reader, all_rels_loaded)
{
}
- protected override void HandleCreateInc(StringBuilder builder)
+ protected override void HandleCreateInc (StringBuilder builder)
{
- if(releases == null)
- AppendIncParameters(builder, "releases");
- if(puids == null)
- AppendIncParameters(builder, "puids");
- base.HandleCreateInc(builder);
+ if (releases == null) AppendIncParameters (builder, "releases");
+ if (puids == null) AppendIncParameters (builder, "puids");
+ base.HandleCreateInc (builder);
}
- protected override void HandleLoadMissingData()
+ protected override void HandleLoadMissingData ()
{
- Track track = new Track(MBID, CreateInc());
+ Track track = new Track (MBID, CreateInc ());
duration = track.Duration;
- if(releases == null)
- releases = track.Releases;
- if(puids == null)
- puids = track.Puids;
- base.HandleLoadMissingData(track);
+ if (releases == null) releases = track.Releases;
+ if (puids == null) puids = track.Puids;
+ base.HandleLoadMissingData (track);
}
- protected override bool HandleAttributes(XmlReader reader)
+ protected override bool HandleAttributes (XmlReader reader)
{
return true;
}
- protected override bool HandleXml(XmlReader reader)
+ protected override bool HandleXml (XmlReader reader)
{
- reader.Read();
- bool result = base.HandleXml(reader);
- if(!result) {
+ reader.Read ();
+ bool result = base.HandleXml (reader);
+ if (!result) {
result = true;
- switch(reader.Name) {
+ switch (reader.Name) {
case "duration":
- reader.Read();
- if(reader.NodeType == XmlNodeType.Text)
- duration = uint.Parse(reader.ReadContentAsString());
+ reader.Read ();
+ if (reader.NodeType == XmlNodeType.Text) duration = uint.Parse (reader.ReadContentAsString ());
break;
case "release-list":
- if(reader.ReadToDescendant("release")) {
- releases = new List<Release>();
- do releases.Add(new Release(reader.ReadSubtree()));
- while(reader.ReadToNextSibling("release"));
+ if(reader.ReadToDescendant ("release")) {
+ releases = new List<Release> ();
+ do releases.Add (new Release (reader.ReadSubtree ()));
+ while (reader.ReadToNextSibling ("release"));
}
break;
case "puid-list":
- if(reader.ReadToDescendant("puid")) {
- puids = new List<string>();
- do puids.Add(reader["id"]);
- while(reader.ReadToNextSibling("puid"));
+ if(reader.ReadToDescendant ("puid")) {
+ puids = new List<string> ();
+ do puids.Add (reader ["id"]);
+ while (reader.ReadToNextSibling ("puid"));
}
break;
default:
- reader.Skip(); // FIXME this is a workaround for Mono bug 334752
+ reader.Skip (); // FIXME this is a workaround for Mono bug 334752
result = false;
break;
}
}
- reader.Close();
+ reader.Close ();
return result;
}
#region Properties
- [Queryable("trid")]
- public override string MBID
- {
+ [Queryable ("trid")]
+ public override string MBID {
get { return base.MBID; }
}
- [Queryable("track")]
- public override string Title
- {
+ [Queryable ("track")]
+ public override string Title {
get { return base.Title; }
}
uint duration;
- [Queryable("dur")]
- public uint Duration
- {
+ [Queryable ("dur")]
+ public uint Duration {
get { return duration; }
}
List<Release> releases;
- [QueryableMember("Contains", "release")]
- public List<Release> Releases
- {
- get { return GetPropertyOrNew<List<Release>>(ref releases); }
+ [QueryableMember ("Contains", "release")]
+ public List<Release> Releases {
+ get { return GetPropertyOrNew<List<Release>> (ref releases); }
}
List<string> puids;
- public List<string> Puids
- {
- get { return GetPropertyOrNew<List<string>>(ref puids); }
+ public List<string> Puids {
+ get { return GetPropertyOrNew<List<string>> (ref puids); }
}
- public int GetTrackNumber(Release release)
+ public int GetTrackNumber (Release release)
{
- if(release == null)
- throw new ArgumentNullException("release");
- foreach(Release r in Releases)
- if(r.Equals(release))
+ if (release == null) throw new ArgumentNullException ("release");
+
+ foreach (Release r in Releases)
+ if (r.Equals (release))
return r.TrackNumber;
return -1;
}
#endregion
- public static Track Get(string mbid)
+ public static Track Get (string mbid)
{
- if(mbid == null)
- throw new ArgumentNullException("mbid");
-
- return new Track(mbid);
+ if (mbid == null) throw new ArgumentNullException ("mbid");
+ return new Track (mbid);
}
#region Query
- public static Query<Track> Query(string title)
+ public static Query<Track> Query (string title)
{
- if(title == null)
- throw new ArgumentNullException("title");
+ if (title == null) throw new ArgumentNullException ("title");
- TrackQueryParameters parameters = new TrackQueryParameters();
+ TrackQueryParameters parameters = new TrackQueryParameters ();
parameters.Title = title;
- return Query(parameters);
+ return Query (parameters);
}
- public static Query<Track> Query(string title, string release)
+ public static Query<Track> Query (string title, string release)
{
- if(title == null)
- throw new ArgumentNullException("title");
+ if (title == null) throw new ArgumentNullException ("title");
+ if (release == null) throw new ArgumentNullException ("release");
- if(release == null)
- throw new ArgumentNullException("release");
-
- TrackQueryParameters parameters = new TrackQueryParameters();
+ TrackQueryParameters parameters = new TrackQueryParameters ();
parameters.Title = title;
parameters.Release = release;
- return Query(parameters);
+ return Query (parameters);
}
- public static Query<Track> Query(string title, string release, string artist)
+ public static Query<Track> Query (string title, string release, string artist)
{
- if(title == null)
- throw new ArgumentNullException("title");
-
- if(release == null)
- throw new ArgumentNullException("release");
-
- if(artist == null)
- throw new ArgumentNullException("artist");
+ if (title == null) throw new ArgumentNullException ("title");
+ if (release == null) throw new ArgumentNullException ("release");
+ if (artist == null) throw new ArgumentNullException ("artist");
- TrackQueryParameters parameters = new TrackQueryParameters();
+ TrackQueryParameters parameters = new TrackQueryParameters ();
parameters.Title = title;
parameters.Release = release;
parameters.Artist = artist;
- return Query(parameters);
+ return Query (parameters);
}
- public static Query<Track> Query(TrackQueryParameters parameters)
+ public static Query<Track> Query (TrackQueryParameters parameters)
{
- if(parameters == null)
- throw new ArgumentNullException("parameters");
-
- return new Query<Track>(EXTENSION, QueryLimit, parameters.ToString());
+ if (parameters == null) throw new ArgumentNullException ("parameters");
+ return new Query<Track> (EXTENSION, QueryLimit, parameters.ToString ());
}
- public static Query<Track> QueryLucene(string lucene_query)
+ public static Query<Track> QueryLucene (string luceneQuery)
{
- if(lucene_query == null)
- throw new ArgumentNullException("lucene_query");
-
- return new Query<Track>(EXTENSION, QueryLimit, CreateLuceneParameter(lucene_query));
+ if(luceneQuery == null) throw new ArgumentNullException ("luceneQuery");
+ return new Query<Track> (EXTENSION, QueryLimit, CreateLuceneParameter (luceneQuery));
}
#endregion
- public static implicit operator string(Track t)
+ public static implicit operator string (Track track)
{
- return t.ToString();
+ return track.ToString ();
}
}
}
\ No newline at end of file
Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utilities.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utilities.cs (original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utilities.cs Thu Feb 21 22:07:32 2008
@@ -13,37 +13,35 @@
{
internal static class Utilities
{
- public static string EnumToString(Enum enumeration)
+ public static string EnumToString (Enum enumeration)
{
- string str = enumeration.ToString();
- StringBuilder builder = new StringBuilder(str.Length);
- builder.Append(str[0]);
- for(int i = 1; i < str.Length; i++) {
- if(str[i] >= 'A' && str[i] <= 'Z') {
- builder.Append('-');
- }
- builder.Append(str[i]);
+ string str = enumeration.ToString ();
+ StringBuilder builder = new StringBuilder (str.Length);
+ builder.Append (str [0]);
+ for (int i = 1; i < str.Length; i++) {
+ if (str [i] >= 'A' && str [i] <= 'Z') builder.Append ('-');
+ builder.Append (str [i]);
}
- return builder.ToString();
+ return builder.ToString ();
}
- public static string PercentEncode(string value)
+ public static string PercentEncode (string value)
{
- StringBuilder builder = new StringBuilder();
- PercentEncode(builder, value);
- return builder.ToString();
+ StringBuilder builder = new StringBuilder ();
+ PercentEncode (builder, value);
+ return builder.ToString ();
}
- public static void PercentEncode(StringBuilder builder, string value)
+ public static void PercentEncode (StringBuilder builder, string value)
{
- foreach(char c in value) {
- if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') ||
+ foreach (char c in value) {
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') ||
c == '-' || c == '_' || c == '.' || c == '~')
- builder.Append(c);
+ builder.Append (c);
else {
- builder.Append('%');
- foreach(byte b in Encoding.UTF8.GetBytes(new char[] { c }))
- builder.Append(string.Format("{0:X}", b));
+ builder.Append ('%');
+ foreach (byte b in Encoding.UTF8.GetBytes (new char [] { c }))
+ builder.Append (string.Format ("{0:X}", b));
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]