public static int Parse(string s, NumberStyles style, IFormatProvider formatProvider) { Exception e; int res; if (!ParseHelper.Parse(s, style, formatProvider, false, out res, out e)) { throw e; } return(res); }
public static IDictionary <string, TValue> ToDictionary <TValue>(this object obj) { //TODO: we can cache the fields and properties per type. Dictionary <string, TValue> result = new Dictionary <string, TValue>(); if (obj != null) { foreach (PropertyInfo property in obj.GetType().GetProperties()) { try { object value = property.GetValue(obj, null); result.Add(property.Name, ParseHelper.Parse <TValue>(value.ToString())); } catch { } //Don't bother doing anything if a problem was encountered. } } return(result); }
public static bool TryParse(string s, NumberStyles style, IFormatProvider format, out int result) { Exception e; return(ParseHelper.Parse(s, style, format, true, out result, out e)); }