addAutoMap<TSource extends AutoMapperModel, TTarget> method

void addAutoMap<TSource extends AutoMapperModel, TTarget>(
  1. TTarget expression(
    1. Map<String, dynamic>
    )
)

Adds a function that defines how to auto map from a TSource to a TTarget type.

Implementation

void addAutoMap<TSource extends AutoMapperModel, TTarget>(
  TTarget Function(Map<String, dynamic>) expression,
) {
  if (hasMap(TTarget, TSource)) {
    throw MapDuplicateError(TTarget, TSource);
  }
  if (!_autoMaps.containsKey(TTarget)) {
    _autoMaps[TTarget] = <Type, AutoMapConfiguration>{};
  }
  final conf = AutoMapConfiguration<TSource, TTarget>(expression);
  _autoMaps[TTarget]![TSource] = conf;
}