WMapper 1.0.2

dotnet add package WMapper --version 1.0.2
                    
NuGet\Install-Package WMapper -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WMapper" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WMapper" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="WMapper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WMapper --version 1.0.2
                    
#r "nuget: WMapper, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WMapper@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WMapper&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=WMapper&version=1.0.2
                    
Install as a Cake Tool

WMapper

WMapper is a very simple object-to-object mapper. It was created to be extremely plug-and-play, meaning one library, a few lines to add the service, and everything else is you defining your mappings. As of today, there is no auto-mapping.

Example usage: You can find a sample here.

The setup is straightforward. For any service-related usage, use the services.AddMapper(options => ...) extension method provided. For example:

var collection = new ServiceCollection();
collection.AddMapper(builder =>
{
    builder.Register<UserDbo, UserDto, UserMapper>();
});

This will add a singleton registration of type IMapper (implementation type of Mapper) and register the specified adapter (in this case UserMapper) for the specified conversion types (in this case UserDbo -> UserDto).

In other cases, it is preferable to use an instance of IMapperBuilder, registering your adapters and then building into an instance of IMapper. This package comes with the MapperBuilder class for this purpose.

Adapters

There are two ways to register adapters. The first one is to use the generic overload provided by the IMapperBuilder interface that requires you to specify the type of the adapter.

builder.Register<X, Y, XtoYAdapter>()

This will also handle any required dependency injection when creating XtoYAdapter.

The second way is to use the generic overload that requires an instance of IAdapter<TFrom, TTo>:

builder.Register<X, Y>(new XtoYAdapter())

Adapting

To actually use the IMapper in your code, you have the interface-provided T Adapt<T>(object src, Type srcType); method, where srcType is the type of the src parameter that was registered during configuration. The builder does not recognize childrens as valid registered types and will throw if you try to adapt to/from a non-registered type.

You can also use the extension method:

mapper.Adapt<Y>(new X());

Be careful as this simply does a .GetType() on the provided src parameter. If you are adapting from a child of X to Y, you can use the second extension method:

mapper.Adapt<X, Y>(new ChildofX());
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 220 5/12/2025