public Temperature(float value, KnownUnits units = KnownUnits.Celsius) : base(value, UnitTable.Lookup(units)) { }
public Length(float value, KnownUnits units = KnownUnits.Meters) : base(value, UnitTable.Lookup(units)) { }
public Voltage(float value, KnownUnits units = KnownUnits.Volts) : base(value, UnitTable.Lookup(units)) { }
public Duration(float value, KnownUnits units = KnownUnits.Seconds) : base(value, __unitTable.Lookup(units)) { }
private static double?GetReminderSeconds(string content) { var trailingText = content.Substring(content.IndexOf(Constants.RemindMe) + Constants.RemindMe.Length); foreach (var phrase in KnownPhrases.Keys) { if (trailingText.IndexOf(phrase) > -1) { return(KnownPhrases[phrase]); } } var bits = new List <string>(trailingText.Split(new[] { ' ', '.', ',' }, StringSplitOptions.RemoveEmptyEntries)); if (bits.Count < 1) { return(null); } // Ignore everything until you hit a number you can parse. for (var i = 0; i < bits.Count; i++) { try { Parse(bits[i]); break; } catch (Exception) { bits.RemoveAt(i); if (bits.Count > 0) { i = i - 1; } else { return(null); } } } double quantity; if (!TryParse(bits[0], out quantity)) { return(null); } double multiplier; if (bits.Count < 2 || !KnownUnits.ContainsKey(bits[1])) { return(null); } else { multiplier = KnownUnits[bits[1].ToLowerInvariant()]; } return(quantity * multiplier); }