forked from exilon/QuickLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quick.AutoMapper.pas
565 lines (497 loc) · 18.7 KB
/
Quick.AutoMapper.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
{ ***************************************************************************
Copyright (c) 2015-2020 Kike Pérez
Unit : Quick.AutoMapper
Description : Auto Mapper object properties
Author : Kike Pérez
Version : 1.5
Created : 25/08/2018
Modified : 07/04/2020
This file is part of QuickLib: https://github.com/exilon/QuickLib
***************************************************************************
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*************************************************************************** }
unit Quick.AutoMapper;
{$i QuickLib.inc}
interface
uses
SysUtils,
Generics.Collections,
typinfo,
Quick.Value,
{$IFDEF FPC}
Variants,
{$ENDIF}
RTTI,
Quick.RTTI.Utils;
//enable use of property paths (like namespaces) in custom mapping
{$DEFINE PROPERTYPATH_MODE}
type
{$IFNDEF FPC}
TFlexValue = TValue;
{$ELSE}
TFlexValue = variant;
{$ENDIF}
{$IFNDEF FPC}
TMappingProc<TClass1> = reference to procedure(const aSrcObj : TClass1; const aTargetName : string; out Value : TFlexValue);
TAfterMappingProc<TClass1,TClass2> = reference to procedure(const aSrcObj : TClass1; aTgtObj : TClass2);
{$ELSE}
TMappingProc<TObject> = procedure(const aSrcObj : TObject; const aTargetName : string; out Value : TFlexValue) of object;
TAfterMappingProc<TClass1,TClass2> = procedure(const aSrcObj : TClass1; aTgtObj : TClass2) of object;
{$ENDIF}
TCustomMapping = class
private
fMapDictionary : TDictionary<string,string>;
public
constructor Create;
destructor Destroy; override;
procedure AddMap(const aName, aMapName : string);
function GetMap(const aName : string; out vMapName : string) : Boolean;
function Count : Integer;
end;
TObjMapper = class
public
class procedure Map(aSrcObj : TObject; aTgtObj : TObject; aCustomMapping: TCustomMapping = nil); overload;
{$IFNDEF FPC}
class procedure Map<Tm>(aSrcObj : TObject; aTgtObj : TObject; aDoMappingProc : TMappingProc<Tm>; aCustomMapping: TCustomMapping = nil); overload;
{$ELSE}
class procedure Map(aSrcObj : TObject; aTgtObj : TObject; aDoMappingProc : TMappingProc<TObject>; aCustomMapping: TCustomMapping = nil); overload;
{$ENDIF}
end;
TListMapper = class
public
class procedure Map(aSrcList, aTgtList: TObject; aCustomMapping: TCustomMapping);
end;
TObjListMapper = class
public
class procedure Map(aSrcObjList : TObject; aTgtObjList : TObject; aCustomMapping : TCustomMapping = nil); overload;
{$IFNDEF FPC}
class procedure Map<Tm>(aSrcObjList : TObject; aTgtObjList : TObject; aDoMappingProc : TMappingProc<Tm>; aCustomMapping : TCustomMapping = nil); overload;
{$ELSE}
class procedure Map(aSrcObjList : TObject; aTgtObjList : TObject; aDoMappingProc : TMappingProc<TObject>; aCustomMapping : TCustomMapping = nil); overload;
{$ENDIF}
end;
{$IFNDEF FPC}
TMapper = class
public
class function Map<T : class, constructor>(aSrcObj : TObject) : T;
end;
{$ENDIF}
TMapper<T : class, constructor> = class
public
class function Map(aSrcObj : TObject; aCustomMapping: TCustomMapping = nil): T; overload;
class procedure Map(aSrcObj : TObject; aTgtObj : T; aCustomMapping : TCustomMapping = nil); overload;
{$IFNDEF FPC}
class function Map<Tm>(aSrcObj : TObject; aDoMappingProc : TMappingProc<Tm>; aCustomMapping: TCustomMapping = nil): T; overload;
class procedure Map<Tm>(aSrcObj : TObject; aTgtObj : T; aDoMappingProc : TMappingProc<Tm>; aCustomMapping: TCustomMapping = nil); overload;
{$ELSE}
class function Map(aSrcObj : TObject; aDoMappingProc : TMappingProc<TObject>; aCustomMapping: TCustomMapping = nil): T; overload;
class procedure Map(aSrcObj : TObject; aTgtObj : T; aDoMappingProc : TMappingProc<TObject>; aCustomMapping: TCustomMapping);
{$ENDIF}
end;
IAutoMapper<TClass1, TClass2 : class, constructor> = interface
['{9F7B2DEA-76D8-4DD1-95D0-22C22AEB5DD0}']
function Map(aSrcObj : TClass1) : TClass2; overload;
{$IFNDEF FPC}
function Map(aSrcObj : TClass2) : TClass1; overload;
procedure SetOnDoMapping(CustomProc : TMappingProc<TClass1>);
procedure SetOnAfterMapping(CustomProc : TAfterMappingProc<TClass1,TClass2>);
{$ELSE}
//freepascal detects overload with generic types as duplicated function, added dummy field to avoid this
function Map(aSrcObj : TClass2; dummy : Boolean = True) : TClass1; overload;
{$ENDIF}
end;
TAutoMapper<TClass1, TClass2 : class, constructor> = class(TInterfacedObject, IAutoMapper<TClass1, TClass2>)
private
fCustomMapping : TCustomMapping;
{$IFNDEF FPC}
fOnDoMapping : TMappingProc<TClass1>;
{$ELSE}
fOnDoMapping : TMappingProc<TObject>;
{$ENDIF}
fOnAfterMapping : TAfterMappingProc<TClass1,TClass2>;
public
constructor Create;
destructor Destroy; override;
property CustomMapping : TCustomMapping read fCustomMapping write fCustomMapping;
{$IFNDEF FPC}
property OnDoMapping : TMappingProc<TClass1> read fOnDoMapping write fOnDoMapping;
{$ELSE}
property OnDoMapping : TMappingProc<TObject> read fOnDoMapping write fOnDoMapping;
{$ENDIF}
property OnAfterMapping : TAfterMappingProc<TClass1,TClass2> read fOnAfterMapping write fOnAfterMapping;
function Map(aSrcObj : TClass1) : TClass2; overload;
{$IFNDEF FPC}
function Map(aSrcObj : TClass2) : TClass1; overload;
procedure SetOnDoMapping(CustomProc : TMappingProc<TClass1>);
procedure SetOnAfterMapping(CustomProc : TAfterMappingProc<TClass1,TClass2>);
{$ELSE}
//freepascal detects overload with generic types as duplicated function, added dummy field to avoid this
function Map(aSrcObj : TClass2; dummy : Boolean = True) : TClass1; overload;
{$ENDIF}
end;
EAutoMapperError = class(Exception);
implementation
{ TObjMapper }
class procedure TObjMapper.Map(aSrcObj : TObject; aTgtObj : TObject; aCustomMapping: TCustomMapping = nil);
begin
Map{$IFNDEF FPC}<TObject>{$ENDIF}(aSrcObj,aTgtObj,nil,aCustomMapping);
end;
{$IFNDEF FPC}
class procedure TObjMapper.Map<Tm>(aSrcObj : TObject; aTgtObj : TObject; aDoMappingProc : TMappingProc<Tm>; aCustomMapping: TCustomMapping = nil);
{$ELSE}
class procedure TObjMapper.Map(aSrcObj : TObject; aTgtObj : TObject; aDoMappingProc : TMappingProc<TObject>; aCustomMapping: TCustomMapping = nil);
{$ENDIF}
var
ctx : TRttiContext;
rType : TRttiType;
tgtprop : TRttiProperty;
mapname : string;
obj : TObject;
manualmapping : Boolean;
value : TFlexValue;
{$IFNDEF FPC}
clname : string;
objvalue : TValue;
{$ENDIF}
begin
//if aTgtObj = nil then aTgtObj := GetTypeData(aTgtObj.ClassInfo).classType.Create;
if aTgtObj = nil then raise EAutoMapperError.Create('TObjMapper: Target Object passed must be created before');
{$IFNDEF FPC}
objvalue := TValue.From(aSrcObj);
{$ENDIF}
rType := ctx.GetType(aSrcObj.ClassInfo);
for tgtprop in ctx.GetType(aTgtObj.ClassInfo).GetProperties do
begin
if tgtprop.IsWritable then
begin
if not tgtprop.PropertyType.IsInstance then
begin
if Assigned(aCustomMapping) and (not Assigned(aDoMappingProc)) then
begin
if aCustomMapping.GetMap(tgtprop.Name,mapname) then
begin
{$IFNDEF PROPERTYPATH_MODE}
if rType.GetProperty(mapname) = nil then raise EAutoMapperError.CreateFmt('No valid custom mapping (Source: %s - Target: %s)',[mapname,tgtprop.Name]);
begin
try
{$IFNDEF FPC}
tgtprop.SetValue(aTgtObj,rType.GetProperty(mapname).GetValue(aSrcObj));
{$ELSE}
SetPropValue(aTgtObj,tgtprop.Name,GetPropValue(aSrcObj,mapname));
{$ENDIF}
except
on E : Exception do raise EAutoMapperError.CreateFmt('Error mapping property "%s" : %s',[tgtprop.Name,e.message]);
end;
end;
{$ELSE}
if not TRTTI.PathExists(aSrcObj,mapname) then raise EAutoMapperError.CreateFmt('No valid custom mapping (Source: %s - Target: %s)',[mapname,tgtprop.Name]);
TRTTI.SetPathValue(aTgtObj,tgtprop.Name,TRTTI.GetPathValue(aSrcObj,mapname));
{$ENDIF}
end
else
begin
if rType.GetProperty(tgtprop.Name) <> nil then
try
{$IFNDEF FPC}
tgtprop.SetValue(aTgtObj,rType.GetProperty(tgtprop.Name).GetValue(aSrcObj));
{$ELSE}
SetPropValue(aTgtObj,tgtprop.Name,GetPropValue(aSrcObj,tgtprop.Name));
{$ENDIF}
except
on E : Exception do raise EAutoMapperError.CreateFmt('Error mapping property "%s" : %s',[tgtprop.Name,e.message]);
end;
end;
end
else
begin
try
if Assigned(aDoMappingProc) then
begin
{$IFNDEF FPC}
aDoMappingProc(objvalue.AsType<Tm>,tgtprop.Name,value);
manualmapping := not value.IsEmpty;
{$ELSE}
aDoMappingProc(aSrcObj,tgtprop.Name,value);
manualmapping := not varType(value) = varEmpty;
{$ENDIF}
end
else manualmapping := False;
if manualmapping then
begin
{$IFNDEF FPC}
tgtprop.SetValue(aTgtObj,value);
{$ELSE}
SetPropValue(aTgtObj,tgtprop.Name,value);
{$ENDIF}
end
else
begin
{$IFNDEF FPC}
if rType.GetProperty(tgtprop.Name) <> nil then tgtprop.SetValue(aTgtObj,rType.GetProperty(tgtprop.Name).GetValue(aSrcObj));
{$ELSE}
if rType.GetProperty(tgtprop.Name) <> nil then SetPropValue(aTgtObj,tgtprop.Name,GetPropValue(aSrcObj,tgtprop.Name));
{$ENDIF}
end;
except
on E : Exception do raise EAUtoMapperError.CreateFmt('Error mapping property "%s" : %s',[tgtprop.Name,e.message]);
end;
end;
end
else
begin
obj := tgtprop.GetValue(aTgtObj).AsObject;
{$IFNDEF FPC}
if obj = nil then obj := GetObjectProp(aSrcObj,tgtprop.Name).ClassType.Create;// TObject.Create;
{$ELSE}
if obj = nil then obj := GetObjectProp(aSrcObj,tgtprop.Name).ClassType.Create;
{$ENDIF}
if obj <> nil then
begin
{$IFNDEF FPC}
try
if (rType.GetProperty(tgtprop.Name) <> nil)
and (not rType.GetProperty(tgtprop.Name).GetValue(aSrcObj).IsEmpty) then clname := rType.GetProperty(tgtprop.Name).GetValue(aSrcObj).AsObject.ClassName
else Continue;
except
on E : Exception do raise EAUtoMapperError.CreateFmt('Error mapping property "%s" : %s',[tgtprop.Name,e.message]);
end;
if clname.StartsWith('TObjectList') then TObjListMapper.Map(rType.GetProperty(tgtprop.Name).GetValue(aSrcObj).AsObject,obj,aCustomMapping)
else TObjMapper.Map(rType.GetProperty(tgtprop.Name).GetValue(aSrcObj).AsObject,obj,aCustomMapping)
{$ELSE}
TObjMapper.Map(GetObjectProp(aSrcObj,tgtprop.Name),obj,aCustomMapping);
SetObjectProp(aTgtObj,tgtprop.Name,obj);
{$ENDIF}
end
else raise EAutoMapperError.CreateFmt('Target object "%s" not autocreated by class',[tgtprop.Name]);
end;
end;
end;
end;
class function TMapper<T>.Map(aSrcObj : TObject; aCustomMapping: TCustomMapping = nil) : T;
begin
Result := Map{$IFNDEF FPC}<TObject>{$ENDIF}(aSrcObj,nil,aCustomMapping);
end;
{$IFNDEF FPC}
class function TMapper<T>.Map<Tm>(aSrcObj : TObject; aDoMappingProc : TMappingProc<Tm>; aCustomMapping: TCustomMapping = nil): T;
{$ELSE}
class function TMapper<T>.Map(aSrcObj : TObject; aDoMappingProc : TMappingProc<TObject>; aCustomMapping: TCustomMapping = nil): T;
{$ENDIF}
var
obj : T;
begin
obj := T.Create;
{$IFNDEF FPC}
TObjMapper.Map<Tm>(aSrcObj,obj,aDoMappingProc,aCustomMapping);
{$ELSE}
TObjMapper.Map(aSrcObj,obj,aDoMappingProc,aCustomMapping);
{$ENDIF}
Result := obj;
end;
class procedure TMapper<T>.Map(aSrcObj : TObject; aTgtObj : T; aCustomMapping : TCustomMapping = nil);
begin
{$IFNDEF FPC}
Map<T>(aSrcObj,aTgtObj,nil,aCustomMapping);
{$ELSE}
Map(aSrcObj,aTgtObj,nil,aCustomMapping);
{$ENDIF}
end;
{$IFNDEF FPC}
class procedure TMapper<T>.Map<Tm>(aSrcObj : TObject; aTgtObj : T; aDoMappingProc : TMappingProc<Tm>; aCustomMapping : TCustomMapping = nil);
{$ELSE}
class procedure TMapper<T>.Map(aSrcObj : TObject; aTgtObj : T; aDoMappingProc : TMappingProc<TObject>; aCustomMapping : TCustomMapping);
{$ENDIF}
begin
{$IFNDEF FPC}
TObjMapper.Map<Tm>(aSrcObj, aTgtObj, aDoMappingProc, aCustomMapping);
{$ELSE}
TObjMapper.Map(aSrcObj, aTgtObj, aDoMappingProc, aCustomMapping);
{$ENDIF}
end;
{ TAutoMapper<TClass1, TClass2> }
constructor TAutoMapper<TClass1, TClass2>.Create;
begin
fCustomMapping := TCustomMapping.Create;
fOnDoMapping := nil;
fOnAfterMapping := nil;
end;
destructor TAutoMapper<TClass1, TClass2>.Destroy;
begin
if Assigned(fCustomMapping) then fCustomMapping.Free;
fOnDoMapping := nil;
fOnAfterMapping := nil;
inherited;
end;
function TAutoMapper<TClass1, TClass2>.Map(aSrcObj: TClass1): TClass2;
var
objvalue : TValue;
obj : TObject;
begin
obj := aSrcObj as TObject;
//objvalue := TValue.From(aSrcObj).AsObject;
{$IFNDEF FPC}
Result := TMapper<TClass2>.Map<TClass1>(obj,fOnDoMapping,fCustomMapping);
{$ELSE}
Result := TMapper<TClass2>.Map(obj,fOnDoMapping,fCustomMapping);
{$ENDIF}
if Assigned(fOnAfterMapping) then fOnAfterMapping(aSrcObj,Result);
end;
{$IFNDEF FPC}
function TAutoMapper<TClass1, TClass2>.Map(aSrcObj: TClass2): TClass1;
begin
Result := TMapper<TClass1>.Map<TClass1>(aSrcObj,fOnDoMapping,fCustomMapping);
end;
procedure TAutoMapper<TClass1, TClass2>.SetOnAfterMapping(CustomProc: TAfterMappingProc<TClass1, TClass2>);
begin
fOnAfterMapping := CustomProc;
end;
procedure TAutoMapper<TClass1, TClass2>.SetOnDoMapping(CustomProc: TMappingProc<TClass1>);
begin
fOnDoMapping := CustomProc;
end;
{$ELSE}
function TAutoMapper<TClass1, TClass2>.Map(aSrcObj: TClass2; dummy : Boolean = True): TClass1;
begin
Result := TMapper<TClass1>.Map(aSrcObj,fOnDoMapping,fCustomMapping);
end;
{$ENDIF}
{ TCustomMapping }
procedure TCustomMapping.AddMap(const aName, aMapName: string);
begin
//add map fields
fMapDictionary.Add(aName,aMapName);
//add reverse lookup if not same name
if aName <> aMapName then fMapDictionary.Add(aMapName,aName);
end;
function TCustomMapping.Count: Integer;
begin
Result := fMapDictionary.Count;
end;
constructor TCustomMapping.Create;
begin
fMapDictionary := TDictionary<string,string>.Create;
end;
destructor TCustomMapping.Destroy;
begin
fMapDictionary.Free;
inherited;
end;
function TCustomMapping.GetMap(const aName: string; out vMapName: string): Boolean;
begin
Result := fMapDictionary.TryGetValue(aName,vMapName);
end;
{ TListMapper }
class procedure TListMapper.Map(aSrcList, aTgtList: TObject; aCustomMapping: TCustomMapping);
{$IFNDEF FPC}
var
rtype: TRttiType;
rtype2 : TRttiType;
typinfo : PTypeInfo;
methToArray: TRttiMethod;
value: TValue;
valuecop : TValue;
obj : TObject;
i : Integer;
rprop : TRttiProperty;
ctx : TRttiContext;
begin
rtype := ctx.GetType(aSrcList.ClassInfo);
methToArray := rtype.GetMethod('ToArray');
if Assigned(methToArray) then
begin
value := methToArray.Invoke(aSrcList,[]);
Assert(value.IsArray);
rtype2 := ctx.GetType(aTgtList.ClassInfo);
rProp := rtype2.GetProperty('List');
typinfo := GetTypeData(rProp.PropertyType.Handle).DynArrElType^;
case typinfo.Kind of
tkChar, tkString, tkWChar, tkWString : TList<string>(aTgtList).Capacity := value.GetArrayLength;
tkInteger, tkInt64 : TList<Integer>(aTgtList).Capacity := value.GetArrayLength;
tkFloat : TList<Extended>(aTgtList).Capacity := value.GetArrayLength;
else TList<TObject>(aTgtList).Capacity := value.GetArrayLength;
end;
for i := 0 to value.GetArrayLength - 1 do
begin
if typinfo.Kind = tkClass then
begin
obj := typinfo.TypeData.ClassType.Create;
TObjMapper.Map(value.GetArrayElement(i).AsObject,obj,aCustomMapping);
TList<TObject>(aTgtList).Add(obj);
end
else
begin
valuecop := value.GetArrayElement(i);
case typinfo.Kind of
tkChar, tkString, tkWChar, tkWString : TList<string>(aTgtList).Add(valuecop.AsString);
tkInteger, tkInt64 : TList<Integer>(aTgtList).Add(valuecop.AsInt64);
tkFloat : TList<Extended>(aTgtList).Add(valuecop.AsExtended);
end;
end;
end;
end;
end;
{$ELSE}
begin
end;
{$ENDIF}
{ TObjListMapper }
class procedure TObjListMapper.Map(aSrcObjList, aTgtObjList: TObject; aCustomMapping: TCustomMapping);
begin
{$IFNDEF FPC}
Map<TObject>(aSrcObjList,aTgtObjList,nil,aCustomMapping);
{$ELSE}
Map(aSrcObjList,aTgtObjList,nil,aCustomMapping);
{$ENDIF}
end;
{$IFNDEF FPC}
class procedure TObjListMapper.Map<Tm>(aSrcObjList : TObject; aTgtObjList : TObject; aDoMappingProc : TMappingProc<Tm>; aCustomMapping : TCustomMapping = nil);
var
rtype: TRttiType;
rtype2 : TRttiType;
typinfo : PTypeInfo;
methToArray: TRttiMethod;
value: TValue;
obj : TObject;
i : Integer;
rprop : TRttiProperty;
ctx : TRttiContext;
begin
rtype := ctx.GetType(aSrcObjList.ClassInfo);
methToArray := rtype.GetMethod('ToArray');
if Assigned(methToArray) then
begin
value := methToArray.Invoke(aSrcObjList,[]);
Assert(value.IsArray);
rtype2 := ctx.GetType(aTgtObjList.ClassInfo);
rProp := rtype2.GetProperty('List');
typinfo := GetTypeData(rProp.PropertyType.Handle).DynArrElType^;
TObjectList<TObject>(aTgtObjList).Capacity := value.GetArrayLength;
for i := 0 to value.GetArrayLength - 1 do
begin
obj := typinfo.TypeData.ClassType.Create;
TObjMapper.Map<Tm>(value.GetArrayElement(i).AsObject,obj,aDoMappingProc,aCustomMapping);
TObjectList<TObject>(aTgtObjList).Add(obj);
end;
end;
end;
{$ELSE}
class procedure TObjListMapper.Map(aSrcObjList : TObject; aTgtObjList : TObject; aDoMappingProc : TMappingProc<TObject>; aCustomMapping : TCustomMapping = nil);
begin
end;
{$ENDIF}
{ TMapper }
{$IFNDEF FPC}
class function TMapper.Map<T>(aSrcObj: TObject): T;
begin
Result := T.Create;
TObjMapper.Map(aSrcObj,Result,nil);
end;
{$ENDIF}
end.