示例#1
0
 public FetchSingleDataLoader(
     FetchCache <TKey, TValue> fetch,
     int cacheSize, DataLoaderOptions <TKey> options)
     : base(options)
 {
     _fetch = fetch ?? throw new ArgumentNullException(nameof(fetch));
 }
 public FetchSingleDataLoader(
     FetchCache <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));
 }
示例#3
0
        public static bool Register <TKey, TValue>(
            this IDataLoaderRegistry registry,
            string key,
            FetchCache <TKey, TValue> fetch)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException(
                          TypeResources.DataLoaderRegistry_KeyNullOrEmpty,
                          nameof(key));
            }

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

            return(registry.Register(key, services =>
                                     new FetchSingleDataLoader <TKey, TValue>(fetch)));
        }
示例#4
0
        public static IDataLoader <TKey, TValue> CacheDataLoader <TKey, TValue>(
            this IResolverContext context,
            string key,
            FetchCache <TKey, TValue> fetch)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException(
                          TypeResources.DataLoaderRegistry_KeyNullOrEmpty,
                          nameof(key));
            }

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

            return(CacheDataLoaderFactory(context, key, services => fetch));
        }
 public FetchSingleDataLoader(FetchCache <TKey, TValue> fetch)
     : this(fetch, DataLoaderDefaults.CacheSize)
 {
 }
示例#6
0
 protected CacheDataLoader(FetchCache <TKey, TValue> fetch)
     : base(_defaultOptions)
 {
 }