Ejemplo n.º 1
0
        GroupDataLoaderFactory <TKey, TValue>(
            this IResolverContext context,
            string key,
            FetchGroupeFactory <TKey, TValue> factory)
        {
            if (TryGetDataLoader(context, key,
                                 out IDataLoader <TKey, TValue[]> dataLoader,
                                 out IDataLoaderRegistry registry))
            {
                return(dataLoader);
            }

            return(GetOrCreate <IDataLoader <TKey, TValue[]> >(
                       key, registry, r => r.Register(key, factory)));
        }
Ejemplo n.º 2
0
        public static bool Register <TKey, TValue>(
            this IDataLoaderRegistry registry,
            string key,
            FetchGroupeFactory <TKey, TValue> factory)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException(
                          TypeResources.DataLoaderRegistry_KeyNullOrEmpty,
                          nameof(key));
            }

            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            return(registry.Register(key, services =>
                                     new FetchGroupedDataLoader <TKey, TValue>(
                                         factory(services))));
        }