示例#1
0
        private Task <TResource> Find(TKey key, CsDataFindOptions options)
        {
            TResource cached;

            if (resources.TryGetValue(key, out cached))
            {
                return(Task.FromResult(cached));
            }

            lock (this.inFlightLock)
            {
                Task <TResource> inFlight;
                if (!this.inFlight.TryGetValue(key, out inFlight))
                {
                    this.inFlight[key] = inFlight = this.adapter.Find <TKey, TResource>(key);
                    inFlight.ContinueWith(t =>
                    {
                        if (t.IsCompleted)
                        {
                            this.Inject(new[] { t.Result }, options);
                        }
                        lock (this.inFlightLock)
                        {
                            this.inFlight.Remove(key);
                        }
                    });
                }

                return(inFlight);
            }
        }
示例#2
0
 Task <IEnumerable <TResource> > ICsDataResource <TKey, TResource> .FindAll <TQuery>(TQuery query, CsDataFindOptions options)
 {
     throw new NotImplementedException();
 }
示例#3
0
 Task <TResource> ICsDataResource <TKey, TResource> .Find(TKey key, CsDataFindOptions options)
 {
     return(this.Find(key, options ?? CsDataFindOptions.Default));
 }