??????????????????????????????????????????????????????д??????????????????????????????????????????????????????
?????????.net 4.5
public static D Mapper<D?? S>(S s)
{
D d = Activator.CreateInstance<D>();
try
{
var sType = s.GetType();
var dType = typeof(D);
foreach (PropertyInfo sP in sType.GetProperties())
{
foreach (PropertyInfo dP in dType.GetProperties())
{
if (dP.Name == sP.Name)
{
dP.SetValue(d?? sP.GetValue(s));
}
}
}
}
catch (Exception ex)
{
}
return d;
}