Releases: TinyMapper/TinyMapper
Releases · TinyMapper/TinyMapper
3.0.3
Add new Map method
added: public static object Map(Type sourceType, Type targetType, object source, object target = null)
Thanks to: izaruba
fixed static fields mapping
public class MapWithStaticFields
{
[Fact]
public void MapStaticFields()
{
var source = new SourceStatic();
TinyMapper.Bind<SourceStatic, TargetDto>();
var actual = TinyMapper.Map<TargetDto>(source);
Assert.Equal(SourceStatic.Id, actual.Id);
Assert.Equal(SourceStatic.Name, actual.Name);
}
}
public class SourceStatic
{
public static string Name = "test";
public static int Id = 1;
}
public class TargetDto
{
public int Id { get; set; }
public string Name { get; set; }
}
Thanks to Summitn
Version 2.1.4-beta
- added support supports circular reference mapping
Thanks to: sergiorykov, xihu69
var source = new Node
{
Id = "1",
Next = new Node
{
Id = "2",
Next = new Node
{
Id = "3",
Child = new[]
{
new Node
{
Id = " 123 1"
},
new Node
{
Id = "123 2"
}
}
}
},
Child = new[]
{
new Node
{
Id = "1 1"
},
new Node
{
Id = "1 2"
}
}
};
TinyMapper.Bind<Node, Node>();
var target = TinyMapper.Map<Node, Node>(source);
Assert.Equal(source.Id, target.Id);
Assert.Equal(source.Next.Id, target.Next.Id);
Assert.Equal(source.Next.Next.Id, target.Next.Next.Id);
Assert.Equal(source.Next.Next.Id, target.Next.Next.Id);
Assert.Equal(source.Next.Next.Child, target.Next.Next.Child);
Assert.Equal(source.Child, target.Child);
Version 2.1.3-beta
- Improved mapping, i.e. now it's possible to map properties from other classes
source.Address.Street
TinyMapper.Bind<PersonDto, Person>(
config =>
{
config.Bind(source => source.Address.Street, target => target.Street);
config.Bind(source => source.Address.Phone, target => target.Phone);
}
);
Version 2.1.2-beta
- Collection mapping has been improved
Before
Method | Mean | Error | StdDev |
---|---|---|---|
CollectionMapping_AutoMapper | 27.753 us | 0.1789 us | 0.1494 us |
CollectionMapping_TinyMapper | 9.594 us | 0.0912 us | 0.0853 us |
CollectionMapping_Handwritten | 3.560 us | 0.0709 us | 0.0729 us |
After
Method | Mean | Error | StdDev |
---|---|---|---|
CollectionMapping_AutoMapper | 27.696 us | 0.5117 us | 1.2259 us |
CollectionMapping_TinyMapper | 6.765 us | 0.0660 us | 0.0618 us |
CollectionMapping_Handwritten | 3.521 us | 0.0387 us | 0.0343 us |
Version 2.1.1-beta
Version 2.0.8
fixed: DeepCloneable member binding with custom mapping
Thanks to: Gaclaudiu
Version 2.0.6
fixed: Case sensitive binding
Thanks to: Lecamarade
Version 2.0.5
TinyMapper allows to set concrete type if required, i.e.
public class Source
{
public IList<int> Ints { get; set; }
public List<string> Strings { get; set; }
}
public class Target
{
public List<int> Ints { get; set; }
public IEnumerable<string> Strings { get; set; }
}
TinyMapper.Bind<Source, Target>(config =>
{
config.Bind(target => target.Strings, typeof(List<string>));
});
Thanks to: Teknogecko, oryol