banshee r3686 - in trunk/musicbrainz-sharp/src/MusicBrainz: . MusicBrainz



Author: scottp
Date: Sun Apr  6 04:08:18 2008
New Revision: 3686
URL: http://svn.gnome.org/viewvc/banshee?rev=3686&view=rev

Log:
* src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs,
  src/MusicBrainz/MusicBrainz/Release.cs,
  src/MusicBrainz/MusicBrainz/MusicBrainzEntity.cs,
  src/MusicBrainz/MusicBrainz/Utils.cs,
  src/MusicBrainz/MusicBrainz/Track.cs,
  src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs: Some better string
  building.

Modified:
   trunk/musicbrainz-sharp/src/MusicBrainz/ChangeLog
   trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzEntity.cs
   trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzItem.cs
   trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
   trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs
   trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs
   trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs

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	Sun Apr  6 04:08:18 2008
@@ -121,7 +121,10 @@
         
         protected static string CreateNameParameter (string name)
         {
-            return "&name=" + Utils.PercentEncode (name);
+            StringBuilder builder = new StringBuilder (name.Length + 6);
+            builder.Append ("&name=");
+            Utils.PercentEncode (builder, name);
+            return builder.ToString ();
         }
         
         #endregion

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	Sun Apr  6 04:08:18 2008
@@ -158,8 +158,12 @@
             set { count = value; }
         }
 
-        protected void AppendBaseToBuilder (StringBuilder builder)
+        protected abstract void ToStringCore (StringBuilder builder);
+        
+        public override string ToString ()
         {
+            StringBuilder builder = new StringBuilder ();
+            ToStringCore (builder);
             if (title != null) {
                 builder.Append ("&title=");
                 Utils.PercentEncode (builder, title);
@@ -184,6 +188,7 @@
                 builder.Append ("&count=");
                 builder.Append (count.Value);
             }
+            return builder.ToString ();
         }
     }
     

Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs	(original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/MusicBrainzObject.cs	Sun Apr  6 04:08:18 2008
@@ -281,7 +281,7 @@
 
         #endregion
         
-        #region Public
+        #region Public Methods
         
         public override bool Equals (object obj)
         {
@@ -417,7 +417,10 @@
 
         protected static string CreateLuceneParameter (string query)
         {
-            return "&query=" + Utils.PercentEncode (query);
+            StringBuilder builder = new StringBuilder (query.Length + 7);
+            builder.Append ("&query=");
+            Utils.PercentEncode (builder, query);
+            return builder.ToString ();
         }
 
         internal static List<T> Query<T> (string url_extension,

Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs	(original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Release.cs	Sun Apr  6 04:08:18 2008
@@ -373,9 +373,8 @@
             set { script = value; }
         }
 
-        public override string ToString ()
+        protected override void ToStringCore (StringBuilder builder)
         {
-            StringBuilder builder = new StringBuilder ();
             if (disc_id != null) {
                 builder.Append ("&discid=");
                 builder.Append (disc_id);
@@ -396,8 +395,6 @@
                 builder.Append ("&script=");
                 builder.Append (script);
             }
-            AppendBaseToBuilder (builder);
-            return builder.ToString ();
         }
     }
     

Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs	(original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Track.cs	Sun Apr  6 04:08:18 2008
@@ -266,9 +266,8 @@
             set { puid = value; }
         }
 
-        public override string ToString ()
+        protected override void ToStringCore (StringBuilder builder)
         {
-            StringBuilder builder = new StringBuilder ();
             if (release != null) {
                 builder.Append ("&release=");
                 Utils.PercentEncode (builder, release);
@@ -289,8 +288,6 @@
                 builder.Append ("&puid=");
                 builder.Append (puid);
             }
-            AppendBaseToBuilder (builder);
-            return builder.ToString ();
         }
     }
     

Modified: trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs
==============================================================================
--- trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs	(original)
+++ trunk/musicbrainz-sharp/src/MusicBrainz/MusicBrainz/Utils.cs	Sun Apr  6 04:08:18 2008
@@ -63,13 +63,6 @@
             return null;
         }
         
-        public static string PercentEncode (string value)
-        {
-            StringBuilder builder = new StringBuilder ();
-            PercentEncode (builder, value);
-            return builder.ToString ();
-        }
-        
         public static void PercentEncode (StringBuilder builder, string value)
         {
             foreach (char c in value) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]