protected override void PostElementParse(ref List <Match> .Enumerator tokens, AppenderValue appenderValue, string aggregate = null) { string unit; if (!string.IsNullOrEmpty(aggregate)) { var t = StandardUnit.FindValue(aggregate.ToLowerInvariant()); if (t.ToString() != aggregate.ToLowerInvariant()) //If conversion capitalizes unit then it is valid and should not be included in rest. { ((MetricDatumAppenderValue)appenderValue).Unit = aggregate; return; } } if (tokens.MoveNext()) { if (!string.IsNullOrEmpty(unit = tokens.Current.Groups["word"].Value)) { var t = StandardUnit.FindValue(unit.ToLowerInvariant()); if (t.ToString() != unit.ToLowerInvariant()) //If conversion capitalizes unit then it is valid and should not be included in rest. { tokens.MoveNext(); ((MetricDatumAppenderValue)appenderValue).Unit = unit; } } } }
public object ConvertFrom(object source) { return(StandardUnit.FindValue(source as string)); }