private FormatBase GetNumberFormat(string format, object value) { FormatBase expectedFormat = NumberFormats.Where(f => f.Format == "G").ToList().FirstOrDefault(); if (!string.IsNullOrEmpty(format)) { string leader = format[0].ToString(); NumberFormat n = NumberFormats.Where(f => f.Format == leader).ToList().FirstOrDefault() as NumberFormat; if (n != null) { string decimalPlaces = format.Substring(1); if (!string.IsNullOrEmpty(decimalPlaces)) { int num; if (Int32.TryParse(decimalPlaces, out num)) { n.DecimalPlaces = num; } } expectedFormat = n; } else { DateFormat d = NumberFormats.Where(f => f.Name == "Date").FirstOrDefault() as DateFormat; if (d.IsDateFormat(format, value)) { expectedFormat = d; } } } return(expectedFormat); }