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