Skip to content

Commit 1d4fde9

Browse files
committed
AgileMapper 1.8 blog post
1 parent 813beab commit 1d4fde9

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

AgileObjects.Jekyll.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.0</TargetFramework>
3+
<TargetFramework>net5</TargetFramework>
44
</PropertyGroup>
55
<ItemGroup>
66
<Compile Remove="_site\**" />
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
layout: post
3+
title: AgileMapper v1.8 Released
4+
excerpt: AgileMapper 1.8 is now on NuGet with refinements, fixes, and a new option for configuring data sources.
5+
tags: [AgileMapper]
6+
---
7+
8+
_AgileMapper is a powerful and unopinionated object mapper for .NET 3.5+ and .NET Standard 1.0+. It
9+
flattens, unflattens, deep clones, merges, updates and projects queries. It works without configuration,
10+
but if needed, is highly and easily configurable._
11+
12+
AgileMapper 1.8 is now available [on NuGet]({{ site.am_nuget }}) with refinements, fixes, and a new
13+
option for
14+
[configuring data sources]({{ site.am_docs }}/configuration/Member-Values#applying-data-sources-with-a-matcher).
15+
16+
## Configuring Matcher Data Sources
17+
18+
AgileMapper has long supported
19+
[ignoring target members]({{ site.am_docs }}/configuration/Ignoring-Target-Members#target-member-filtering)
20+
(and [source members]({{ site.am_docs }}/configuration/Ignoring-Source-Members#source-member-filtering))
21+
using filters - `Func`s which match members based on their types, names, paths, attributes, etc. The
22+
same filters can now be used to configure source values to matched target members.
23+
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:
27+
28+
```csharp
29+
// Configure bool -> string mappings to map 'Yes' or 'No'
30+
// if the target string member has a YesOrNoAttribute:
31+
Mapper.WhenMapping
32+
.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+
```
37+
38+
[This DotNetFiddle](https://dotnetfiddle.net/LVTd2z){:target="_blank"} shows a live example.
39+
40+
## Ignoring Unusual Base Class Library Classes
41+
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,
45+
Dictionaries, etc. This makes for faster mapper creation.
46+
47+
## NET Standard 2.0 Target
48+
49+
As a downstream consequence of a .NET Standard 2.0 target being added to
50+
[ReadableExpressions]({{ site.re_github }}), AgileMapper now has an additional .NET Standard 2.0
51+
target. This makes it more easily consumable from packages or apps which target .NET Standard 2.0.
52+
With support going all the way back to .NET Framework 3.5, AgileMapper is an option for a very wide
53+
range of projects!
54+
55+
Please report any issues or suggestions [on GibHub]({{ site.am_github }}/issues). Happy mapping!

0 commit comments

Comments
 (0)