Exemplo n.º 1
0
 public IStrategy <T, TInput, TOutput> GetStrategy(UnorderedPair <T> objects)
 {
     if (!HasStrategy(objects))
     {
         return(null);
     }
     return(strats[new UnorderedPair <Type>(objects.Item1.GetType(), objects.Item2.GetType())]);
 }
Exemplo n.º 2
0
 protected Strategy(Type t1, Type t2)
 {
     if (!t1.GetInterfaces().Contains(typeof(T)))
     {
         throw new ArgumentException(nameof(t1));
     }
     if (!t2.GetInterfaces().Contains(typeof(T)))
     {
         throw new ArgumentException(nameof(t2));
     }
     ValidTypes = new UnorderedPair <Type>(t1, t2);
 }
Exemplo n.º 3
0
 public bool Equals(UnorderedPair <T> other) => (other.Item1.Equals(Item1) && other.Item2.Equals(Item2)) || (other.Item1.Equals(Item2) && other.Item2.Equals(Item1));
Exemplo n.º 4
0
 public bool HasStrategy(UnorderedPair <T> objects) => strats.ContainsKey(new UnorderedPair <Type>(objects.Item1.GetType(), objects.Item2.GetType()));
Exemplo n.º 5
0
 public bool AreObjectsValid(UnorderedPair <T> objects) => new UnorderedPair <Type>(objects.Item1.GetType(), objects.Item2.GetType()).Equals(ValidTypes);