Beispiel #1
0
        public static object FillField(object instance, PropertyInfo propertyInfo, DataRow dataRow, bool defaultValueUsed)
        {
            ColumnAttribute a = Reflex.GetColumnAttribute(dataRow, propertyInfo);

            if (a != null)
            {
                object value = dataRow[a.ColumnName];

                if (value == System.DBNull.Value)
                {
                    if (a.DefaultValue != null)
                    {
                        value = a.DefaultValue;
                    }
                    else if (defaultValueUsed)
                    {
                        Type dataType = dataRow.Table.Columns[a.ColumnName].DataType;
                        value = DefaultRowValue.SystemDefaultValue(dataType);
                    }
                    else
                    {
                        value = null;
                    }
                }

                propertyInfo.SetValue(instance, value, null);
            }

            return(a);
        }
Beispiel #2
0
        public virtual void Clear()
        {
            foreach (PropertyInfo propertyInfo in this.columnProperties)
            {
                object value = null;

                if (propertyInfo.PropertyType.IsValueType)
                {
                    value = DefaultRowValue.SystemDefaultValue(propertyInfo.PropertyType);
                }

                propertyInfo.SetValue(this, value, null);
            }
        }