private void SetValue(Type editableRootType, DetailsSaveFieldModel field, IEditableRoot editableRoot) { var prop = editableRootType.GetProperty(field.SystemName); if (prop != null) { if (_handlers.ContainsKey(field.FieldType)) field.Value = _handlers[field.FieldType].GetValue(field, editableRoot); if (field.FieldType == ColumnTypes.Reference) { int? value = new int?(Convert.ToInt32(field.Value)); prop.SetValue(editableRoot, value); return; } if (field.FieldType == ColumnTypes.MultiReference) { SetMultiReferenceValue(field, editableRoot); return; } if (field.FieldType == ColumnTypes.Numeric) { decimal? value = new decimal?(Convert.ToDecimal(field.Value)); prop.SetValue(editableRoot, value); return; } if (field.FieldType == ColumnTypes.Frequency) { SetFrequencyValue(field, editableRoot); return; } if (field.FieldType == ColumnTypes.SampleType) { SetSampleTypeValue(field, editableRoot); return; } prop.SetValue(editableRoot, field.Value); } else SetValue(editableRoot.GetBaseEdit().GetType(), field, editableRoot.GetBaseEdit()); }
private static object GetValue(PropertyInfo prop, IEditableRoot editableRoot) { if (editableRoot == null) throw new ArgumentNullException("editableRoot"); if (editableRoot.GetType().GetProperty(prop.Name) != null) return prop.GetValue(editableRoot); return GetValue(prop, editableRoot.GetBaseEdit()); }