Skip to content

Commit 00a2fdd

Browse files
committed
Updating blog
1 parent b7699ac commit 00a2fdd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

_posts/2021-05-06-agilemapper-v1_8.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,30 @@ using filters - `Func`s which match members based on their types, names, paths,
2222
same filters can now be used to configure source values to matched target members.
2323

2424
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:
2727

2828
```csharp
2929
// 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:
3134
Mapper.WhenMapping
3235
.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();
3640
```
3741

3842
[This DotNetFiddle](https://dotnetfiddle.net/LVTd2z){:target="_blank"} shows a live example.
3943

4044
## Ignoring Unusual Base Class Library Classes
4145

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,
4549
Dictionaries, etc. This makes for faster mapper creation.
4650

4751
## NET Standard 2.0 Target

0 commit comments

Comments
 (0)