private static void Map(object source, Type sourceType, object destination, Type destinationType, bool assumeDestinationExplicitly) { DictionaryKey <Type, Type, bool> key = new DictionaryKey <Type, Type, bool>(sourceType, destinationType, assumeDestinationExplicitly); Lazy <Action <object, object> > mappingAction; if (!cachedActions.TryGetValue(key, out mappingAction)) { mappingAction = CacheMappingAction(key); } mappingAction.Value(source, destination); }
private static Type AssumeDestinationActualType(Type initialDestinationType, Type sourceActualType) { DictionaryKey <Type, Type> key = new DictionaryKey <Type, Type>(initialDestinationType, sourceActualType); Lazy <Type> actualType; if (!assumeDestinationActualTypesCache.TryGetValue(key, out actualType)) { actualType = CacheDestinationActualType(key); } return(actualType.Value); }
private static object MapTo(object source, Type sourceType, Type destinationType, bool assumeDestinationExplicitly) { DictionaryKey <Type, Type, bool> key = new DictionaryKey <Type, Type, bool>(sourceType, destinationType, assumeDestinationExplicitly); Lazy <Func <object, object> > mappingFunction; if (!cachedFunctions.TryGetValue(key, out mappingFunction)) { mappingFunction = CacheMappingFunction(key); } return(mappingFunction.Value(source)); }
private static Lazy <Action <object, object> > CacheMappingAction(DictionaryKey <Type, Type, bool> key) { return(cachedActions.GetOrAdd( key, new Lazy <Action <object, object> >(() => GetMappingAction(key.Item1, key.Item2, key.Item3), true))); }
public bool Equals(DictionaryKey <T1, T2> other) { return(DictionaryKey.Equals(this, other)); }
public override bool Equals(object obj) { return(DictionaryKey.Equals(this, obj)); }
public override int GetHashCode() { return(DictionaryKey.GetHashCode(this)); }
private static Lazy <Type> CacheDestinationActualType(DictionaryKey <Type, Type> key) { return(assumeDestinationActualTypesCache.GetOrAdd( key, new Lazy <Type>(() => GetDestinationActualType(key.Item1, key.Item2), true))); }