bool IsFieldExists(String name, DataType dataType, out FieldMetadata fm) { if (_fields.TryGetValue(name, out fm)) { if (fm.DataType != dataType) { throw new DataLoaderException($"Invalid property '{name}'. Type mismatch."); } return(true); } return(false); }
public FieldMetadata AddField(FieldInfo field, DataType type) { if (!field.IsVisible) { return(null); } FieldMetadata fm; if (IsFieldExists(field.PropertyName, type, out fm)) { return(fm); } fm = new FieldMetadata(field, type); _fields.Add(field.PropertyName, fm); switch (field.SpecType) { case SpecType.Id: Id = field.PropertyName; break; case SpecType.Name: Name = field.PropertyName; break; case SpecType.RowNumber: RowNumber = field.PropertyName; break; case SpecType.RowCount: IsRowCount = true; break; case SpecType.HasChildren: HasChildren = field.PropertyName; break; } return(fm); }