using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Threading.Tasks; namespace MEU.API.Utils { public class ModelFactory<PClass, CClass> where PClass : class where CClass : class { public static CClass CloneObject(CClass a, PClass parent) { try { foreach (PropertyInfo prop in parent.GetType().GetProperties()) { var propFound = a.GetType().GetProperty(prop.Name); if (propFound!=null) { propFound.SetValue(a, prop.GetValue(parent, null), null); } } return a; } catch (Exception ex) { Logs.LoggerFactory.ErrorLog(ex.ToString(), "Exception"); throw ex; } } } }