]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Parse.cs
map constants should be case-insensitive
[chaz/carfire] / CarFire / CarFire / CarFire / Parse.cs
index e1a482eb6a08c55398650186bdefd3f45d9fd527..169cf30a7b8340b59af9aa61aae521c9e7c04ad8 100644 (file)
@@ -101,21 +101,19 @@ namespace CarFire
         /// </summary>\r
         /// <typeparam name="T">An enumeration.</typeparam>\r
         /// <param name="atom">Text.</param>\r
-        /// <returns>The constant, or null if parsing failed.</returns>\r
+        /// <returns>The constant, or default(T) if parsing failed.</returns>\r
         public static T Constant<T>(string atom)\r
         {\r
-            string constant = String(atom);\r
-            if (constant != null)\r
+            try\r
             {\r
-                foreach (string enumConstant in System.Enum.GetNames(typeof(T)))\r
-                {\r
-                    if (constant == enumConstant)\r
-                    {\r
-                        return (T)System.Enum.Parse(typeof(T), constant);\r
-                    }\r
-                }\r
+                return (T)System.Enum.Parse(typeof(T), String(atom), true);\r
+            }\r
+#pragma warning disable 0168\r
+            catch (System.Exception ex)\r
+#pragma warning restore 0168\r
+            {\r
+                return default(T);\r
             }\r
-            return default(T);\r
         }\r
 \r
         /// <summary>\r
@@ -171,17 +169,6 @@ namespace CarFire
             return null;\r
         }\r
 \r
-        /// <summary>\r
-        /// Parses a comma-separated list of atoms.\r
-        /// </summary>\r
-        /// <param name="text">Text.</param>\r
-        /// <returns>An array of strings containing the atoms, or null\r
-        /// if parsing failed.</returns>\r
-        public static string[] ParameterList(string text)\r
-        {\r
-            return null;\r
-        }\r
-\r
         /// <summary>\r
         /// Parses a whitespace-separated list of atoms.\r
         /// </summary>\r
This page took 0.01804 seconds and 4 git commands to generate.