[banshee/gtk3] build: tidy GSettingsSchemaExtractor.cs



commit 29c30f60238db519f66106424a1bd47808c8b1f1
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Tue Dec 18 14:10:25 2012 +0000

    build: tidy GSettingsSchemaExtractor.cs
    
    Normalize tabs to spaces, respect HACKING guidelines, remove trailing
    whitespace...

 build/GSettingsSchemaExtractor.cs |  138 ++++++++++++++++++------------------
 1 files changed, 69 insertions(+), 69 deletions(-)
---
diff --git a/build/GSettingsSchemaExtractor.cs b/build/GSettingsSchemaExtractor.cs
index 5af3cca..f9f01d2 100644
--- a/build/GSettingsSchemaExtractor.cs
+++ b/build/GSettingsSchemaExtractor.cs
@@ -37,41 +37,41 @@ public class GSettingsSchemaExtractorProgram
         entries = new Dictionary<string, StringBuilder> ();
 
         foreach (Type type in types) {
-            foreach(FieldInfo field in type.GetFields()) {
-                if(field.FieldType.IsGenericType && 
-                    field.FieldType.GetGenericTypeDefinition().Name.StartsWith("SchemaEntry")) {
-                    
-                    if(field.Name == "Zero") {
+            foreach (FieldInfo field in type.GetFields ()) {
+                if (field.FieldType.IsGenericType &&
+                    field.FieldType.GetGenericTypeDefinition ().Name.StartsWith ("SchemaEntry")) {
+
+                    if (field.Name == "Zero") {
                         continue;
                     }
 
                     object schema = field.GetValue(null);
-                
-                    AddSchemaEntry(schema.GetType().GetField("DefaultValue").GetValue(schema),
-                        GetString(schema, "Namespace"),
-                        GetString(schema, "Key"),
-                        GetString(schema, "ShortDescription"),
-                        GetString(schema, "LongDescription")
+
+                    AddSchemaEntry (schema.GetType ().GetField ("DefaultValue").GetValue (schema),
+                        GetString (schema, "Namespace"),
+                        GetString (schema, "Key"),
+                        GetString (schema, "ShortDescription"),
+                        GetString (schema, "LongDescription")
                     );
                 }
             }
         }
 
-        if(schema_count > 0) {
-            StringBuilder final = new StringBuilder();
-            final.Append("<?xml version=\"1.0\"?>\n");
-            final.Append("<gconfschemafile>\n");
-            final.Append("  <schemalist>\n");
+        if (schema_count > 0) {
+            StringBuilder final = new StringBuilder ();
+            final.Append ("<?xml version=\"1.0\"?>\n");
+            final.Append ("<gconfschemafile>\n");
+            final.Append ("  <schemalist>\n");
 
-			List<string> keys = new List<string>(entries.Keys);
-			keys.Sort();
+            List<string> keys = new List<string> (entries.Keys);
+            keys.Sort ();
+
+            foreach(string key in keys) {
+                final.Append (entries [key]);
+            }
 
-			foreach(string key in keys) {
-				final.Append(entries[key]);
-			}
-			
-            final.Append("  </schemalist>\n");
-            final.Append("</gconfschemafile>\n");
+            final.Append ("  </schemalist>\n");
+            final.Append ("</gconfschemafile>\n");
 
             return final;
         }
@@ -80,49 +80,49 @@ public class GSettingsSchemaExtractorProgram
 
     private static string GetString(object o, string name)
     {
-        FieldInfo field = o.GetType().GetField(name);
-        return (string)field.GetValue(o);
+        FieldInfo field = o.GetType ().GetField (name);
+        return (string)field.GetValue (o);
     }
 
-    private static string GetValueString(Type type, object o, out string gctype)
+    private static string GetValueString (Type type, object o, out string gctype)
     {
-        if(type == typeof(bool)) {
+        if (type == typeof (bool)) {
             gctype = "bool";
-            return o == null ? null : o.ToString().ToLower();
-        } else if(type == typeof(int)) {
+            return o == null ? null : o.ToString ().ToLower ();
+        } else if (type == typeof (int)) {
             gctype = "int";
-        } else if(type == typeof(float) || type == typeof(double)) {
+        } else if (type == typeof (float) || type == typeof (double)) {
             gctype = "float";
-        } else if(type == typeof(string)) {
+        } else if (type == typeof (string)) {
             gctype = "string";
         } else {
             throw new Exception("Unsupported type '" + type + "'");
         }
-        
-        return o == null ? null : o.ToString();
+
+        return o == null ? null : o.ToString ();
     }
 
-    private static void AddSchemaEntry(object value, string namespce, string key, 
+    private static void AddSchemaEntry (object value, string namespce, string key,
         string short_desc, string long_desc)
     {
         schema_count++;
         
-        string full_key = CreateKey(namespce, key);
+        string full_key = CreateKey (namespce, key);
         
-        bool list = value.GetType().IsArray;
-        Type type = list ? Type.GetTypeArray((object [])value)[0] : value.GetType();
+        bool list = value.GetType ().IsArray;
+        Type type = list ? Type.GetTypeArray ((object [])value) [0] : value.GetType ();
         string str_val = null;
         string str_type = null;
         
-        if(list) {
+        if (list) {
             if(value == null || ((object [])value).Length == 0) {
-                GetValueString(type, null, out str_type);
+                GetValueString (type, null, out str_type);
                 str_val = "[]";
             } else {
                 str_val = "[";
                 object [] arr = (object [])value;
                 for(int i = 0; i < arr.Length; i++) {
-                    str_val += GetValueString(type, arr[i], out str_type).Replace(",", "\\,");
+                    str_val += GetValueString (type, arr [i], out str_type).Replace (",", "\\,");
                     if(i < arr.Length - 1) {
                         str_val += ",";
                     }
@@ -130,54 +130,54 @@ public class GSettingsSchemaExtractorProgram
                 str_val += "]";
             }
         } else {
-            str_val = GetValueString(type, value, out str_type);
+            str_val = GetValueString (type, value, out str_type);
         }
  
- 		StringBuilder builder = new StringBuilder();
-        builder.AppendFormat("    <schema>\n");
-        builder.AppendFormat("      <key>/schemas{0}</key>\n", full_key);
-        builder.AppendFormat("      <applyto>{0}</applyto>\n", full_key);
-        builder.AppendFormat("      <owner>banshee</owner>\n");
-        if(!list) {
-            builder.AppendFormat("      <type>{0}</type>\n", str_type);
+        StringBuilder builder = new StringBuilder ();
+        builder.AppendFormat ("    <schema>\n");
+        builder.AppendFormat ("      <key>/schemas{0}</key>\n", full_key);
+        builder.AppendFormat ("      <applyto>{0}</applyto>\n", full_key);
+        builder.AppendFormat ("      <owner>banshee</owner>\n");
+        if (!list) {
+            builder.AppendFormat ("      <type>{0}</type>\n", str_type);
         } else {
-            builder.AppendFormat("      <type>list</type>\n");
-            builder.AppendFormat("      <list_type>{0}</list_type>\n", str_type);
+            builder.AppendFormat ("      <type>list</type>\n");
+            builder.AppendFormat ("      <list_type>{0}</list_type>\n", str_type);
         }
-        builder.AppendFormat("      <default>{0}</default>\n", str_val);
-        builder.AppendFormat("      <locale name=\"C\">\n");
-        builder.AppendFormat("        <short>{0}</short>\n", short_desc);
-        builder.AppendFormat("        <long>{0}</long>\n", long_desc);
-        builder.AppendFormat("      </locale>\n");
-        builder.AppendFormat("    </schema>\n");
-		entries.Add(full_key, builder);
+        builder.AppendFormat ("      <default>{0}</default>\n", str_val);
+        builder.AppendFormat ("      <locale name=\"C\">\n");
+        builder.AppendFormat ("        <short>{0}</short>\n", short_desc);
+        builder.AppendFormat ("        <long>{0}</long>\n", long_desc);
+        builder.AppendFormat ("      </locale>\n");
+        builder.AppendFormat ("    </schema>\n");
+        entries.Add (full_key, builder);
     }
         
-    private static string CamelCaseToUnderCase(string s)
+    private static string CamelCaseToUnderCase (string s)
     {
         string undercase = String.Empty;
-        string [] tokens = Regex.Split(s, "([A-Z]{1}[a-z]+)");
+        string [] tokens = Regex.Split (s, "([A-Z]{1}[a-z]+)");
         
         for(int i = 0; i < tokens.Length; i++) {
-            if(tokens[i] == String.Empty) {
+            if (tokens[i] == String.Empty) {
                 continue;
             }
 
-            undercase += tokens[i].ToLower();
-            if(i < tokens.Length - 2) {
+            undercase += tokens [i].ToLower();
+            if (i < tokens.Length - 2) {
                 undercase += "_";
             }
         }
-        
+
         return undercase;
     }
 
-    private static string CreateKey(string namespce, string key)
+    private static string CreateKey (string namespce, string key)
     {
-        return namespce == null 
-            ? "/apps/banshee/" + CamelCaseToUnderCase(key)
-            : "/apps/banshee/" + CamelCaseToUnderCase(namespce.Replace(".", "/")) 
-                + "/" + CamelCaseToUnderCase(key);
+        return namespce == null
+            ? "/apps/banshee/" + CamelCaseToUnderCase (key)
+            : "/apps/banshee/" + CamelCaseToUnderCase (namespce.Replace (".", "/"))
+                + "/" + CamelCaseToUnderCase (key);
     } 
 }
 



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