namespace Shared; public class GenericMapper where T : class where U : class { private HashSet> mapper = new HashSet>(); public T? GetT(U u) { var found = mapper.Where(t => ReferenceEquals(t.Item2, u)); if (found.Count() != 1) { return null; } return found.First().Item1; } public U? GetU(T t) { var found = mapper.Where(u => ReferenceEquals(u.Item1, t)); if (found.Count() != 1) { return null; } return found.First().Item2; } public void Add(T model, U entity) { var tuple = new Tuple(model, entity); mapper.Add(tuple); } public void Reset() { mapper.Clear(); } }