Example #1
0
        public Task GetOrAdd(string key, Func <Task> serviceMethod, Type taskResultType, string[] metricsKeys, IMethodCachingSettings settings)
        {
            var getValueTask = Task.Run(() => GetOrAdd(key, () =>
                                                       TaskConverter.ToWeaklyTypedTask(serviceMethod(), taskResultType), metricsKeys, settings));

            return(TaskConverter.ToStronglyTypedTask(getValueTask, taskResultType));
        }
        public object Invoke(MethodInfo targetMethod, object[] args)
        {
            // TODO: Add caching to this step to prevent using reflection every call
            var resultReturnType = targetMethod.ReturnType.GetGenericArguments().SingleOrDefault() ?? typeof(object);
            var request          = new HttpServiceRequest(targetMethod, args);

            return(TaskConverter.ToStronglyTypedTask(Invoke(request, resultReturnType), resultReturnType));
        }
Example #3
0
        public Task GetOrAdd(string key, Func <Task> factory, Type taskResultType, CacheItemPolicyEx policy, params string[] metricsKeys)
        {
            var getValueTask = GetOrAdd(key, () => TaskConverter.ToWeaklyTypedTask(factory(), taskResultType), policy, metricsKeys, taskResultType);

            return(TaskConverter.ToStronglyTypedTask(getValueTask, taskResultType));
        }