@@ -22,26 +22,30 @@ using filters - `Func`s which match members based on their types, names, paths,
22
22
same filters can now be used to configure source values to matched target members.
23
23
24
24
For example, say you have a set of source models with ` bool ` properties which map to target model
25
- ` string ` members, which expect "1" or "0" instead of true or false. By marking your target members
26
- with ` YesOrNoAttribute ` s, this can be configured like so:
25
+ ` string ` members, which expect ` "Yes" ` or ` "No" ` instead of true or false. By marking your target
26
+ members with ` YesOrNoAttribute ` s, this can be configured like so:
27
27
28
28
``` csharp
29
29
// Configure bool -> string mappings to map 'Yes' or 'No'
30
- // if the target string member has a YesOrNoAttribute:
30
+ // if the target string member has a YesOrNoAttribute
31
+
32
+ // ToTarget() applies the source value to any matching
33
+ // target string member:
31
34
Mapper .WhenMapping
32
35
.From <bool >().To <string >()
33
- .IfTargetMemberMatches (m => m .HasAttribute <YesOrNoAttribute >())
34
- .Map ((bl , str ) => bl ? " Yes" : " No" ) // <- 'bl' is the source bool value
35
- .ToTarget (); // <- ToTarget() applies the source value to any matching target string member
36
+ .IfTargetMemberMatches (m =>
37
+ m .HasAttribute <YesOrNoAttribute >())
38
+ .Map ((bl , str ) => bl ? " Yes" : " No" )
39
+ .ToTarget ();
36
40
```
37
41
38
42
[ This DotNetFiddle] ( https://dotnetfiddle.net/LVTd2z ) {: target ="_ blank"} shows a live example.
39
43
40
44
## Ignoring Unusual Base Class Library Classes
41
45
42
- AgileMapper now ignores BCL classes which aren't commonly used in models. Previously , if a model had
43
- a ` PropertyInfo ` member (for example) , AgileMapper would try to figure out how to map it, find that
44
- it couldn't, and move on. It now skips BCL types except those usually found in models - Lists,
46
+ AgileMapper now ignores BCL classes which aren't commonly used in models. For example , if a model
47
+ has a ` PropertyInfo ` member, AgileMapper would previously try to figure out how to map it, find that
48
+ it couldn't, and move on. It now skips BCL classes except those usually found in models - Lists,
45
49
Dictionaries, etc. This makes for faster mapper creation.
46
50
47
51
## NET Standard 2.0 Target
0 commit comments