MiniMapr 1.1.0
dotnet add package MiniMapr --version 1.1.0
NuGet\Install-Package MiniMapr -Version 1.1.0
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="MiniMapr" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiniMapr" Version="1.1.0" />
<PackageReference Include="MiniMapr" />
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 MiniMapr --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MiniMapr, 1.1.0"
#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.
#addin nuget:?package=MiniMapr&version=1.1.0
#tool nuget:?package=MiniMapr&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Using MiniMapr for Object Mapping in .NET
To install the package:
dotnet add package MiniMapr
Defining the Source and Target Classes
Suppose you have the following domain and DTO classes:
public class User
{
public string Name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public Address Address { get; set; }
}
public class UserDto
{
public string Name { get; set; }
public string EmailAddress { get; set; }
public string Password { get; set; } = "";
public AddressDto Address { get; set; }
}
public class Address
{
public string Street { get; set; }
}
public class AddressDto
{
public string Street { get; set; }
}
Creating Mapping Configuration Classes
To define mappings, create classes that implement IMapperConfig. Inside the Configure method, register your mappings using the MapperService instance provided.
Example:
using MiniMapr;
public class UserMappingConfig : IMapperConfig
{
public void Configure(MapperService mapper)
{
mapper.Add<User, UserDto>(config =>
{
config.IgnoredProperties.Add("Password");
config.CustomMappings["Email"] = "EmailAddress";
config.AddCustomTransformation<Address, AddressDto>("Address", address =>
mapper.Map<Address, AddressDto>(address));
});
}
}
public class AddressMappingConfig : IMapperConfig
{
public void Configure(MapperService mapper)
{
mapper.Add<Address, AddressDto>();
}
}
Registering MiniMap in Dependency Injection
To use MiniMapr in a .NET application, register the configuration classes during startup using AddMapper:
var services = new ServiceCollection();
services.AddMapper(mapper =>
{
mapper.Add<UserMappingConfig>()
.Add<AddressMappingConfig>();
});
var serviceProvider = services.BuildServiceProvider();
var mapperService = serviceProvider.GetRequiredService<IMapper>();
Using the Mapper Once registered, you can use the mapper as follows:
var user = new User
{
Name = "Alice",
Email = "alice@email.com",
Password = "secret123",
Address = new Address { Street = "123 Maple St" }
};
var userDto = mapperService.Map<User, UserDto>(user);
Console.WriteLine(userDto.Name); // Alice
Console.WriteLine(userDto.EmailAddress); // alice@email.com
Console.WriteLine(userDto.Password); // (empty)
Console.WriteLine(userDto.Address.Street); // 123 Maple St
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.3)
- MiniMapr.Core (>= 1.1.0)
-
net9.0
- Microsoft.Extensions.DependencyInjection (>= 9.0.3)
- MiniMapr.Core (>= 1.1.0)
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.1.0 | 160 | 2 months ago |