36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
namespace Swan.Mappers {
|
|
/// <summary>
|
|
/// Represents an object map.
|
|
/// </summary>
|
|
/// <typeparam name="TSource">The type of the source.</typeparam>
|
|
/// <typeparam name="TDestination">The type of the destination.</typeparam>
|
|
/// <seealso cref="IObjectMap" />
|
|
public class ObjectMap<TSource, TDestination> : IObjectMap {
|
|
internal ObjectMap(IEnumerable<PropertyInfo> intersect) {
|
|
this.SourceType = typeof(TSource);
|
|
this.DestinationType = typeof(TDestination);
|
|
this.Map = intersect.ToDictionary(property => this.DestinationType.GetProperty(property.Name), property => new List<PropertyInfo> { this.SourceType.GetProperty(property.Name) });
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public Dictionary<PropertyInfo, List<PropertyInfo>> Map {
|
|
get;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public Type SourceType {
|
|
get;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public Type DestinationType {
|
|
get;
|
|
}
|
|
}
|
|
}
|