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())]); }
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); }
public bool Equals(UnorderedPair <T> other) => (other.Item1.Equals(Item1) && other.Item2.Equals(Item2)) || (other.Item1.Equals(Item2) && other.Item2.Equals(Item1));
public bool HasStrategy(UnorderedPair <T> objects) => strats.ContainsKey(new UnorderedPair <Type>(objects.Item1.GetType(), objects.Item2.GetType()));
public bool AreObjectsValid(UnorderedPair <T> objects) => new UnorderedPair <Type>(objects.Item1.GetType(), objects.Item2.GetType()).Equals(ValidTypes);