Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
 Task <IEnumerable <TResource> > ICsDataResource <TKey, TResource> .FindAll <TQuery>(TQuery query, CsDataFindOptions options)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 3
0
 Task <TResource> ICsDataResource <TKey, TResource> .Find(TKey key, CsDataFindOptions options)
 {
     return(this.Find(key, options ?? CsDataFindOptions.Default));
 }