Type myProperties;
myProperties = this.GetType();
foreach (PropertyInfo pi in myProperties.GetProperties())
{
strDebugPropName = pi.Name;
if (pi.CanWrite && pi.Name.Substring(pi.Name.Length - 1) != "_")
{
switch (pi.PropertyType.ToString())
{
case "System.String":
pi.SetValue(this, TokenSTR(drRec.GetValue(drRec.GetOrdinal(pi.Name))), null);
break;
case "System.DateTime":
pi.SetValue(this, Convert.ToDateTime(drRec.GetValue(drRec.GetOrdinal(pi.Name)).ToString()), null);
break;
case "System.Single":
pi.SetValue(this, Convert.ToSingle(drRec.GetValue(drRec.GetOrdinal(pi.Name)).ToString()), null);
break;
case "System.Int32":
pi.SetValue(this, Convert.ToInt32(drRec.GetValue(drRec.GetOrdinal(pi.Name)).ToString()), null);
break;
default:
break;
}
}
}
For the complete code of the class, you can get it here
0 comments:
Post a Comment