private MvvmLink GetNearestLink(LinkKey key) { MvvmLink result = null; LinkKey bestKey = null; foreach (var link in _viewClasses) { var k = link.Key; if (key.IsAssignableFrom(k)) { //La cle demandée est plus précise que la clé stockée if (bestKey == null || bestKey.IsAssignableFrom(k)) { bestKey = k; result = link.Value; } } if (k.IsAssignableFrom(key)) { // la clé stockée est plus précise que la clé demandée if (bestKey == null || bestKey.IsAssignableFrom(k)) { bestKey = k; result = link.Value; } } } return(result); }
public bool IsAssignableFrom(LinkKey other) => ViewClass.IsAssignableFrom(other.ViewClass) && ViewMode.IsAssignableFrom(other.ViewMode);
protected bool Equals(LinkKey other) { return(ViewClass == other.ViewClass && ViewMode == other.ViewMode); }
public MvvmLink GetLink(LinkKey key) { return(_viewClasses.GetOrAdd(key, GetNearestLink)); }