Esempio n. 1
0
        public static InstanceMapper <TSource, TTarget> GetInstance(MappingContainer container)
        {
            InstanceMapper <TSource, TTarget> mapper;

            if (!_mappers.TryGetValue(container, out mapper))
            {
                lock (_mappers)
                {
                    if (!_mappers.TryGetValue(container, out mapper))
                    {
                        mapper = new InstanceMapper <TSource, TTarget>(container);
                        _mappers.Add(container, mapper);
                    }
                }
            }
            return(mapper);
        }
Esempio n. 2
0
 /// <summary>
 /// Returns a mapper instance for specified types.
 /// </summary>
 /// <typeparam name="TSource">The type of source object.</typeparam>
 /// <typeparam name="TTarget">The type of target object.</typeparam>
 /// <returns>A mapper instance for specified types.</returns>
 public IInstanceMapper <TSource, TTarget> GetMapper <TSource, TTarget>()
 {
     return(InstanceMapper <TSource, TTarget> .GetInstance(this));
 }
Esempio n. 3
0
 /// <summary>
 /// Execute a mapping from the source object to the existing target object.
 /// </summary>
 /// <typeparam name="TSource">The type of source object.</typeparam>
 /// <typeparam name="TTarget">The type of target object.</typeparam>
 /// <param name="source">Source object to map from.</param>
 /// <param name="target">Target object to map into.</param>
 public void Map <TSource, TTarget>(TSource source, TTarget target)
 {
     InstanceMapper <TSource, TTarget> .GetInstance(this).Map(source, target);
 }
Esempio n. 4
0
 /// <summary>
 /// Execute a mapping from the source object to a new target object.
 /// </summary>
 /// <typeparam name="TSource">The type of source object.</typeparam>
 /// <typeparam name="TTarget">The type of target object.</typeparam>
 /// <param name="source">Source object to map from.</param>
 /// <returns>Mapped target object.</returns>
 public TTarget Map <TSource, TTarget>(TSource source)
 {
     return(InstanceMapper <TSource, TTarget> .GetInstance(this).Map(source));
 }