namespace Shared; public static class Extensions { public static U ToU(this T t, GenericMapper mapper, Func func,Action? action = null) where U :class where T :class { var res = mapper.GetU(t); if (res != null) { return res; } U u = func(t); mapper.Add(t, u); if(action != null) action(t, u); return u; } // , Action action public static T ToT(this U u, GenericMapper mapper, Func func,Action? action = null) where U :class where T :class { var result = mapper.GetT(u); if(result != null) return result; T t = func(u); mapper.Add(t, u); if(action != null) action(u, t); return t; } public static void AddRange(this ICollection set, IEnumerable ts) { foreach(var t in ts) { set.Add(t); } } }