Пример #1
0
 public FetchSingleDataLoader(
     FetchSingle <TKey, TValue> fetch,
     int cacheSize)
     : base(new DataLoaderOptions <TKey>
 {
     AutoDispatching   = false,
     Batching          = false,
     CacheSize         = cacheSize,
     MaxBatchSize      = DataLoaderDefaults.MaxBatchSize,
     SlidingExpiration = TimeSpan.Zero
 })
 {
     _fetch = fetch ?? throw new ArgumentNullException(nameof(fetch));
 }
Пример #2
0
        public static IDataLoader <TKey, TValue> DataLoader <TKey, TValue>(
            this IResolverContext context,
            string key,
            FetchSingle <TKey, TValue> fetch)
        {
            if (string.IsNullOrEmpty(key))
            {
                // TODO : resources
                throw new ArgumentException(
                          "The DataLoader key cannot be null or empty.",
                          nameof(key));
            }

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

            return(DataLoader(context, key, services => fetch));
        }
        public static bool Register <TKey, TValue>(
            this IDataLoaderRegistry registry,
            string key,
            FetchSingle <TKey, TValue> fetch)
        {
            if (string.IsNullOrEmpty(key))
            {
                // TODO : Resources
                throw new ArgumentException(
                          "The DataLoader key cannot be null or empty.",
                          nameof(key));
            }

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

            return(registry.Register(key, services =>
                                     new FetchSingleDataLoader <TKey, TValue>(fetch)));
        }
Пример #4
0
 public FetchSingleDataLoader(FetchSingle <TKey, TValue> fetch)
     : this(fetch, DataLoaderDefaults.CacheSize)
 {
 }