/// <summary> /// Maps import fields with specified fluent <paramref name="builder" /> action. /// </summary> /// <param name="fieldName">Name of the field to map.</param> /// <param name="builder">The fluent builder action.</param> /// <returns> /// Fluent builder for <see cref="ImportDefinition" /> /// </returns> /// <exception cref="ArgumentNullException">when the builder action in null</exception> public ImportDefinitionBuilder Field(string fieldName, Action <FieldDefinitionBuilder> builder) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } var fieldMapping = _importDefinition.Fields.FirstOrDefault(m => m.Name == fieldName); if (fieldMapping == null) { fieldMapping = new FieldDefinition { Name = fieldName }; _importDefinition.Fields.Add(fieldMapping); } var fieldBuilder = new FieldDefinitionBuilder(fieldMapping); builder(fieldBuilder); // default type if (fieldMapping.DataType == null) { fieldMapping.DataType = typeof(string); } return(this); }
/// <summary> /// Maps import fields with specified <paramref name="fieldName"/>. /// </summary> /// <param name="fieldName">Name of the field to map.</param> /// <returns>Fluent builder for <see cref="FieldDefinition"/></returns> /// <exception cref="ArgumentNullException">when the field name in null</exception> public FieldDefinitionBuilder Field(string fieldName) { if (fieldName == null) { throw new ArgumentNullException(nameof(fieldName)); } var fieldMapping = _importDefinition.Fields.FirstOrDefault(m => m.Name == fieldName); if (fieldMapping == null) { fieldMapping = new FieldDefinition { Name = fieldName }; _importDefinition.Fields.Add(fieldMapping); } var fieldBuilder = new FieldDefinitionBuilder(fieldMapping); return(fieldBuilder); }