示例#1
0
 public static object ConvertType(object value, Type nType, string nPropertyName)
 {
     try
     {
         if (value == null || value is DBNull)
         {
             return(null);
         }
         else if (nType.Name.ToLower() == "bool" || nType.Name.ToLower() == "boolean")
         {
             return(AppTypes.ToAppBoolean(value));
         }
         else if (nType.Name == "cargomasterNullable`1")
         {
             return(ConvertToNullableValue(value, nType));
         }
         else
         {
             return(Convert.ChangeType(value, nType));
         }
     }
     catch (Exception ex)
     {
         throw new Exception("No se puede cargar el valor [" + AppTypes.GetStringValue(value) + "] de la propiedad " + nPropertyName + ", " + ex.Message, ex);
     }
 }