I'm doing a generic method for rounding values of a class (T), but I also have the classes inside that main (T), these classes I can set this way:
IEnumerable<PropertyInfo> childrenProperties = entidade.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(model => model.PropertyType.Namespace == typeof(T).Namespace).ToArray();
I would like to know how to get the values of these classes, with the main class (T) I simply do this:
foreach (var propertie in decimalPropertiesModel)
{
var value = propertie.GetValue(entidade, null);
if (value != null)
{
propertie.SetValue(entidade, decimal.Round((decimal)value, noCasasDecimais), null);
}
}
But with the other classes I can not do the same thing.
Remembering that this is a generic method, I have the main class CentroWebOnline, I can set all properties and their values of this class, but within that class I also have the CentroChoose class, I want to know how to set the properties and their values of this class CentroChoose.