private HashSet <string> GetNonExistingMappingFields(IReadOnlyMap <string, string> fieldsMapping) { var nonExistingFields = new HashSet <string>(); string mappedFieldName; foreach (var fieldName in base.GetFieldNames()) { if (!fieldsMapping.TryGetKey(fieldName, out mappedFieldName)) { // If nothing maps into current field - ignore continue; } // There is a mapping that results into already existing field, preserve source field name nonExistingFields.Add(mappedFieldName); } // All preserved source field names should be ignored (should not belong to data item), otherwise we have a conflict foreach (var fieldName in base.GetFieldNames()) { if (nonExistingFields.Contains(fieldName) && // this is not a check, just get target field name for the exception message fieldsMapping.TryGetValue(fieldName, out mappedFieldName)) { throw Errors.DataItemAlreadyContainsField(mappedFieldName); } } return(nonExistingFields); }
public override object GetValue(string fieldName) { // Note: Only top-level fields remapping is supported string originalFieldName; return(base.GetValue( fieldsMapping.TryGetKey(fieldName, out originalFieldName) && !inactiveMappings.Contains(originalFieldName) ? originalFieldName : fieldName)); }
private HashSet<string> GetNonExistingMappingFields(IReadOnlyMap<string, string> fieldsMapping) { var nonExistingFields = new HashSet<string>(); string mappedFieldName; foreach (var fieldName in base.GetFieldNames()) { if (!fieldsMapping.TryGetKey(fieldName, out mappedFieldName)) // If nothing maps into current field - ignore continue; // There is a mapping that results into already existing field, preserve source field name nonExistingFields.Add(mappedFieldName); } // All preserved source field names should be ignored (should not belong to data item), otherwise we have a conflict foreach (var fieldName in base.GetFieldNames()) if (nonExistingFields.Contains(fieldName) && // this is not a check, just get target field name for the exception message fieldsMapping.TryGetValue(fieldName, out mappedFieldName)) throw Errors.DataItemAlreadyContainsField(mappedFieldName); return nonExistingFields; }