public static TResult GetOrAddMapReference <TKey, TResult>(TKey key, Func <TKey, TResult> mapFn) { using var context = new MapContextScope(); var dict = context.Context.References; if (!dict.TryGetValue(key !, out var reference)) { dict[key !] = reference = mapFn(key) !;
public static TResult GetOrAddMapReference <TResult>(ReferenceTuple key, Func <ReferenceTuple, TResult> mapFn) where TResult : notnull { using var context = new MapContextScope(); var dict = context.Context.References; if (!dict.TryGetValue(key, out var reference)) { dict[key] = reference = mapFn(key); } return((TResult)reference); }
private MapContextScope createMapContextScope() { var scope = new MapContextScope(); var parameters = scope.Context.Parameters; foreach (var kvp in this.Parameters) { parameters[kvp.Key] = kvp.Value; } return(scope); }
public static TResult GetOrAddMapReference <TKey, TResult>(TKey key, Func <TKey, TResult> mapFn) { using (var context = new MapContextScope()) { var dict = context.Context.References; if (!dict.TryGetValue(key, out var reference)) { dict[key] = reference = mapFn(key); } return((TResult)reference); } }
public TDestination AdaptTo <TDestination>(TDestination destination) { if (_parameters == null) { return(MapToTarget(destination)); } using (var scope = new MapContextScope()) { var parameters = scope.Context.Parameters; foreach (var kvp in _parameters) { parameters[kvp.Key] = kvp.Value; } return(MapToTarget(destination)); } }