public abstract ConvertValue ( object source, IFormatProvider provider ) : object | ||
source | object | |
provider | IFormatProvider | |
리턴 | object |
public override void SetValue(object component, object value) { if (component == null) { return; } if (value != null && _field.ValueType != value.GetType()) { value = _field.ConvertValue(value, System.Globalization.CultureInfo.CurrentCulture); } _field.AsObject((Row)component, value); this.OnValueChanged(component, EventArgs.Empty); }
public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; attr = Target.GetAttribute<LinkingSetRelationAttribute>(); if (attr == null) return false; if (!(row is IIdRow)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but it doesn't implement IIdRow!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } var listType = Target.ValueType; if (!listType.GetIsGenericType() || listType.GetGenericTypeDefinition() != typeof(List<>)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but its property type is not a generic List (e.g. List<int>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } var rowType = attr.RowType; if (rowType.GetIsAbstract() || !typeof(Row).IsAssignableFrom(rowType)) { throw new ArgumentException(String.Format( "Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but specified row type is not valid row class!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } if (!typeof(IIdRow).IsAssignableFrom(rowType)) { throw new ArgumentException(String.Format( "Field '{0}' in row type '{1}' has a LinkingSetRelationBehavior " + "but specified row type doesn't implement IIdRow!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } listFactory = FastReflection.DelegateForConstructor<IList>(listType); rowFactory = FastReflection.DelegateForConstructor<Row>(rowType); listHandlerFactory = FastReflection.DelegateForConstructor<IListRequestProcessor>( typeof(ListRequestHandler<>).MakeGenericType(rowType)); saveHandlerFactory = FastReflection.DelegateForConstructor<ISaveRequestProcessor>( typeof(SaveRequestHandler<>).MakeGenericType(rowType)); saveRequestFactory = FastReflection.DelegateForConstructor<ISaveRequest>( typeof(SaveRequest<>).MakeGenericType(rowType)); deleteHandlerFactory = FastReflection.DelegateForConstructor<IDeleteRequestProcessor>( typeof(DeleteRequestHandler<>).MakeGenericType(rowType)); var detailRow = rowFactory(); thisKeyField = detailRow.FindFieldByPropertyName(attr.ThisKey) ?? detailRow.FindField(attr.ThisKey); if (ReferenceEquals(thisKeyField, null)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a linking set relation in field '{2}' of row type '{3}'.", attr.ThisKey, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.thisKeyCriteria = new Criteria(thisKeyField.PropertyName ?? thisKeyField.Name); itemKeyField = detailRow.FindFieldByPropertyName(attr.ItemKey) ?? detailRow.FindField(attr.ItemKey); if (ReferenceEquals(itemKeyField, null)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a linking set relation in field '{2}' of row type '{3}'.", attr.ItemKey, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); if (!string.IsNullOrEmpty(attr.FilterField)) { this.filterField = detailRow.FindFieldByPropertyName(attr.FilterField) ?? detailRow.FindField(attr.FilterField); if (ReferenceEquals(null, this.filterField)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a linking set relation as FilterField in field '{2}' of row type '{3}'.", attr.FilterField, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.filterCriteria = new Criteria(filterField.PropertyName ?? filterField.Name); this.filterValue = filterField.ConvertValue(attr.FilterValue, CultureInfo.InvariantCulture); if (this.filterValue == null) { this.filterCriteria = this.filterCriteria.IsNull(); this.filterCriteriaT0 = this.filterField.IsNull(); } else { this.filterCriteria = this.filterCriteria == new ValueCriteria(this.filterValue); this.filterCriteriaT0 = this.filterField == new ValueCriteria(this.filterValue); } } return true; }
public bool ActivateFor(Row row) { if (ReferenceEquals(null, Target)) return false; attr = Target.GetAttribute<MasterDetailRelationAttribute>(); if (attr == null) return false; var rowListType = Target.ValueType; if (!rowListType.GetIsGenericType() || rowListType.GetGenericTypeDefinition() != typeof(List<>)) { throw new ArgumentException(String.Format("Field '{0}' in row type '{1}' has a MasterDetailRelationAttribute " + "but its property type is not a generic List (e.g. List<Row>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } var rowType = rowListType.GetGenericArguments()[0]; if (rowType.GetIsAbstract() || !typeof(Row).IsAssignableFrom(rowType)) { throw new ArgumentException(String.Format( "Field '{0}' in row type '{1}' has a MasterDetailRelationAttribute " + "but its property type is not a generic list of rows (e.g. List<Row>)!", Target.PropertyName ?? Target.Name, row.GetType().FullName)); } rowListFactory = FastReflection.DelegateForConstructor<IList>(rowListType); rowFactory = FastReflection.DelegateForConstructor<Row>(rowType); listHandlerFactory = FastReflection.DelegateForConstructor<IListRequestProcessor>( typeof(ListRequestHandler<>).MakeGenericType(rowType)); saveHandlerFactory = FastReflection.DelegateForConstructor<ISaveRequestProcessor>( typeof(SaveRequestHandler<>).MakeGenericType(rowType)); saveRequestFactory = FastReflection.DelegateForConstructor<ISaveRequest>( typeof(SaveRequest<>).MakeGenericType(rowType)); deleteHandlerFactory = FastReflection.DelegateForConstructor<IDeleteRequestProcessor>( typeof(DeleteRequestHandler<>).MakeGenericType(rowType)); var detailRow = rowFactory(); foreignKeyField = detailRow.FindFieldByPropertyName(attr.ForeignKey) ?? detailRow.FindField(attr.ForeignKey); if (ReferenceEquals(foreignKeyField, null)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a master detail relation in field '{2}' of row type '{3}'.", attr.ForeignKey, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.foreignKeyCriteria = new Criteria(foreignKeyField.PropertyName ?? foreignKeyField.Name); if (!string.IsNullOrEmpty(attr.FilterField)) { this.filterField = detailRow.FindFieldByPropertyName(attr.FilterField) ?? detailRow.FindField(attr.FilterField); if (ReferenceEquals(null, this.filterField)) throw new ArgumentException(String.Format("Field '{0}' doesn't exist in row of type '{1}'." + "This field is specified for a master detail relation as FilterField in field '{2}' of row type '{3}'.", attr.FilterField, detailRow.GetType().FullName, Target.PropertyName ?? Target.Name, row.GetType().FullName)); this.filterCriteria = new Criteria(filterField.PropertyName ?? filterField.Name); this.filterValue = filterField.ConvertValue(attr.FilterValue, CultureInfo.InvariantCulture); if (this.filterValue == null) { this.filterCriteria = this.filterCriteria.IsNull(); this.filterCriteriaT0 = this.filterField.IsNull(); } else { this.filterCriteria = this.filterCriteria == new ValueCriteria(this.filterValue); this.filterCriteriaT0 = this.filterField == new ValueCriteria(this.filterValue); } } this.includeColumns = new HashSet<string>(); if (!string.IsNullOrEmpty(attr.IncludeColumns)) foreach (var s in attr.IncludeColumns.Split(',')) { var col = s.TrimToNull(); if (col != null) this.includeColumns.Add(col); } return true; }