示例#1
0
        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);
        }
示例#2
0
 public bool IsAssignableFrom(LinkKey other) => ViewClass.IsAssignableFrom(other.ViewClass) && ViewMode.IsAssignableFrom(other.ViewMode);
示例#3
0
 protected bool Equals(LinkKey other)
 {
     return(ViewClass == other.ViewClass && ViewMode == other.ViewMode);
 }
示例#4
0
 public MvvmLink GetLink(LinkKey key)
 {
     return(_viewClasses.GetOrAdd(key, GetNearestLink));
 }