Exemple #1
0
 /// <summary>
 /// Before populating a target object, generates mappings or loads from cache
 /// </summary>
 /// <param name="target"></param>
 /// <param name="source"></param>
 protected virtual void OnBeforePopulate(TTarget target, TSource source)
 {
     if (CachingStrategy is NullCachingStrategy && !MappingStrategy.GeneratedMappings)
     {
         MappingStrategy.GetMappings(source, typeof(TTarget), MatchingStrategy, AutoMapUnspecifiedTargets);
     }
     else
     {
         var cacheKey       = GetCacheKey();
         var cachedMappings = CachingStrategy.Get(cacheKey) as List <IPropertyMapping>;
         if (cachedMappings == null)
         {
             cachedMappings = MappingStrategy.GetMappings(source, typeof(TTarget), MatchingStrategy, AutoMapUnspecifiedTargets);
             CachingStrategy.Set(cacheKey, cachedMappings);
         }
         else
         {
             MappingStrategy.SetMappings(cachedMappings);
         }
     }
 }