]> Dogcows Code - chaz/carfire/blobdiff - CarFire/CarFire/CarFire/Parse.cs
nevermind, constants should be case-sensitive; renamed Map.Type to Map.Mode to avoid...
[chaz/carfire] / CarFire / CarFire / CarFire / Parse.cs
index b9320778babcbcdfb62d685aec9306ce2639d6c7..be11a9ac506046827f06441b31f67aea3adab07c 100644 (file)
@@ -9,7 +9,8 @@ namespace CarFire
 {\r
     /// <summary>\r
     /// Class with handy static methods taking strings and returning objects\r
-    /// parsed from those strings.\r
+    /// parsed from those strings.  For all of these functions, white space is\r
+    /// generally ignored, but any superfluous characters will make the parse fail.\r
     /// </summary>\r
     public class Parse\r
     {\r
@@ -108,6 +109,18 @@ namespace CarFire
             return null;\r
         }\r
 \r
+        /// <summary>\r
+        /// Parses a single character.\r
+        /// </summary>\r
+        /// <param name="atom">Text.</param>\r
+        /// <returns>The character, or null if parsing failed.</returns>\r
+        public static char? Char(string atom)\r
+        {\r
+            string str = String(atom);\r
+            if (str != null && str.Length == 1) return str[0];\r
+            return null;\r
+        }\r
+\r
         /// <summary>\r
         /// Parses a constant from an enum.\r
         /// </summary>\r
@@ -118,7 +131,7 @@ namespace CarFire
         {\r
             try\r
             {\r
-                return (T)System.Enum.Parse(typeof(T), String(atom), true);\r
+                return (T)System.Enum.Parse(typeof(T), String(atom));\r
             }\r
 #pragma warning disable 0168\r
             catch (System.Exception ex)\r
This page took 0.020748 seconds and 4 git commands to generate.