mirror of https://github.com/abpframework/abp.git
5 changed files with 132 additions and 3 deletions
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.ObjectMapping |
|||
{ |
|||
public interface IMapFrom<in TSource> |
|||
{ |
|||
void MapFrom(TSource source); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
namespace Volo.Abp.ObjectMapping |
|||
{ |
|||
public interface IMapTo<TDestination> |
|||
{ |
|||
TDestination MapTo(); |
|||
|
|||
void MapTo(TDestination destination); |
|||
} |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
using System; |
|||
using Volo.Abp.ObjectMapping; |
|||
|
|||
namespace Volo.Abp.AutoMapper.SampleClasses |
|||
{ |
|||
//TODO: Move tests to Volo.Abp.ObjectMapping test project
|
|||
public class MyEntityDtoWithMappingMethods : IMapFrom<MyEntity>, IMapTo<MyEntity> |
|||
{ |
|||
public Guid Key { get; set; } |
|||
|
|||
public int No { get; set; } |
|||
|
|||
public MyEntityDtoWithMappingMethods() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public MyEntityDtoWithMappingMethods(MyEntity entity) |
|||
{ |
|||
MapFrom(entity); |
|||
} |
|||
|
|||
public void MapFrom(MyEntity source) |
|||
{ |
|||
Key = source.Id; |
|||
No = source.Number; |
|||
} |
|||
|
|||
MyEntity IMapTo<MyEntity>.MapTo() |
|||
{ |
|||
return new MyEntity |
|||
{ |
|||
Id = Key, |
|||
Number = No |
|||
}; |
|||
} |
|||
|
|||
void IMapTo<MyEntity>.MapTo(MyEntity destination) |
|||
{ |
|||
destination.Id = Key; |
|||
destination.Number = No; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue