X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FParse.cs;h=169cf30a7b8340b59af9aa61aae521c9e7c04ad8;hp=e1a482eb6a08c55398650186bdefd3f45d9fd527;hb=7fa101e60a4bc35dfd5dabf8f66811e3f8cfa673;hpb=3b1140cef4f4d429470a130ebf8f4264f7296ca4 diff --git a/CarFire/CarFire/CarFire/Parse.cs b/CarFire/CarFire/CarFire/Parse.cs index e1a482e..169cf30 100644 --- a/CarFire/CarFire/CarFire/Parse.cs +++ b/CarFire/CarFire/CarFire/Parse.cs @@ -101,21 +101,19 @@ namespace CarFire /// /// An enumeration. /// Text. - /// The constant, or null if parsing failed. + /// The constant, or default(T) if parsing failed. public static T Constant(string atom) { - string constant = String(atom); - if (constant != null) + try { - foreach (string enumConstant in System.Enum.GetNames(typeof(T))) - { - if (constant == enumConstant) - { - return (T)System.Enum.Parse(typeof(T), constant); - } - } + return (T)System.Enum.Parse(typeof(T), String(atom), true); + } +#pragma warning disable 0168 + catch (System.Exception ex) +#pragma warning restore 0168 + { + return default(T); } - return default(T); } /// @@ -171,17 +169,6 @@ namespace CarFire return null; } - /// - /// Parses a comma-separated list of atoms. - /// - /// Text. - /// An array of strings containing the atoms, or null - /// if parsing failed. - public static string[] ParameterList(string text) - { - return null; - } - /// /// Parses a whitespace-separated list of atoms. ///