Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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) });
            }
        }
Ejemplo n.º 3
0
 private object GetValueFromDataArray(HeadersMappingInfo mapping)
 {
     return(currentdata[currentRowIndex, mapping.ColumnIndex + 1]);
 }
Ejemplo n.º 4
0
 private PropertyInfo GetPropertyInfo(HeadersMappingInfo mapping)
 {
     return(processingType.GetProperty(mapping.PropertyName));
 }