Exemple #1
0
        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) !;
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
     }
 }
Exemple #5
0
        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));
            }
        }