private IValueConverter CreateAdjacentValueConverter(IUnit source, IUnit target) { KeyValuePair <IUnit, IUnit> id = CreateConverterId(source, target); if (_converters.ContainsKey(id)) { return(_converters[id]); } if (_converters.ContainsKey(ReversedConverterId(id))) { IValueConverter inversedConverter = _converters[ReversedConverterId(id)]; IValueConverter converter = inversedConverter.Inversed(); // Store for later _converters[id] = converter; return(converter); } throw new KeyNotFoundException(string.Format("No converter from '{0}' to '{1}' found.", source, target)); }