/// </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
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