コード例 #1
0
        private object GetValue(int i, DataMap map)
        {
            object value = null;

            if (!string.IsNullOrWhiteSpace(map.ImportColumn))
            {
                GridColumn colImport = gridViewExcelSource.Columns[map.ImportColumn];
                value = gridViewExcelSource.GetRowCellValue(i, colImport);
            }

            value = value ?? map.DefaultValue;
            return(value);
        }
コード例 #2
0
        private static void SetFieldValue(XPObject newObject, DataMap map, object value)
        {
            var fieldType = newObject.ClassInfo.GetPersistentMember(map.PropertyName).MemberType;

            if (value.GetType() != fieldType)
            {
                var result = Convert.ChangeType(value, fieldType);
                newObject.SetMemberValue(map.PropertyName, result);
            }
            else
            {
                newObject.SetMemberValue(map.PropertyName, value);
            }
        }