private void SetValueRegular(HeadersMappingInfo mapping) { var value = GetValueFromDataArray(mapping); PropertyInfo prop = GetPropertyInfo(mapping); if (prop.PropertyType == typeof(DateTime)) { prop.SetValue(CurrentInstance, DateTime.FromOADate((double)Convert.ChangeType(value, typeof(double))), null); } else if (prop.PropertyType == typeof(Guid) || prop.PropertyType == typeof(Guid?)) { string strvalue = (string)value; if (string.IsNullOrWhiteSpace(strvalue)) { prop.SetValue(CurrentInstance, null); } else { prop.SetValue(CurrentInstance, Guid.Parse(strvalue)); } } else { //prop.SetValue(CurrentInstance, Convert.ChangeType(value, prop.PropertyType), null); SetValue(prop, value); } }
private void SetValueDynamicRange(HeadersMappingInfo mapping) { var value = GetValueFromDataArray(mapping); PropertyInfo prop = GetPropertyInfo(mapping); var propertyValue = prop.GetValue(CurrentInstance, null); if (value != null) { prop.PropertyType.GetMethod("Add").Invoke(propertyValue, new[] { GetConvertedValue(value, prop) }); } }
private object GetValueFromDataArray(HeadersMappingInfo mapping) { return(currentdata[currentRowIndex, mapping.ColumnIndex + 1]); }
private PropertyInfo GetPropertyInfo(HeadersMappingInfo mapping) { return(processingType.GetProperty(mapping.PropertyName)); }