Beispiel #1
0
        private static async Task RunAsync(IGraphQlRepository graphQlRepository, Type type, object mappedInstance, string action, IGraphRequestContext graphRequestContext)
        {
            MethodInfo method = graphQlRepository.GetType().GetMethod(action);

            // ReSharper disable once PossibleNullReferenceException
            MethodInfo generic = method.MakeGenericMethod(type);

            var task = (Task)generic.Invoke(graphQlRepository, new[] { mappedInstance, graphRequestContext });

            await task.ConfigureAwait(false);
        }
Beispiel #2
0
        public static async Task DeleteAllAsync(this IGraphQlRepository graphQlRepository, Type type, IGraphRequestContext graphRequestContext)
        {
            MethodInfo method = graphQlRepository.GetType().GetMethod("DeleteAllAsync");

            // ReSharper disable once PossibleNullReferenceException
            MethodInfo generic = method.MakeGenericMethod(type);

            var task = (Task)generic.Invoke(graphQlRepository, new object[] { graphRequestContext });

            await task.ConfigureAwait(false);
        }
Beispiel #3
0
        private static async Task InternalBatchAsync(IGraphQlRepository graphQlRepository, Type type, List <object> items, IGraphRequestContext graphRequestContext, string methodName)
        {
            var listType = typeof(List <>).MakeGenericType(type);
            var list     = Activator.CreateInstance(listType);
            var c        = (IList)list;

            items.ForEach(item => c.Add(item));

            MethodInfo method = graphQlRepository.GetType().GetMethod(methodName);

            // ReSharper disable once PossibleNullReferenceException
            MethodInfo generic = method.MakeGenericMethod(type);

            var task = (Task)generic.Invoke(graphQlRepository, new[] { list, graphRequestContext });

            await task.ConfigureAwait(false);
        }