FromCache() static private method

static private FromCache ( string gamerUuid ) : IList
gamerUuid string
return IList
Esempio n. 1
0
        /// <summary>
        /// Requests the current receipts from the Store. If the Store is not available, the cached
        /// receipts from a previous call are returned.
        /// </summary>
        /// <returns>The list of Receipt objects.</returns>
        public async Task <IList <Receipt> > RequestReceiptsAsync()
        {
            // We need the gamer UUID for the encryption of the cached receipts, so if the dev
            // hasn't retrieved the gamer UUID yet, we'll grab it now.
            var task = Task <IList <Receipt> > .Factory.StartNew(() =>
            {
                if (_gamerInfo == null)
                {
                    _gamerInfo = RequestGamerInfoAsync().Result;
                }
                // No gamerInfo means no receipts
                if (_gamerInfo == null)
                {
                    return(null);
                }
                var tcs      = new TaskCompletionSource <IList <Receipt> >();
                var listener = new ReceiptsListener(tcs, _publicKey, _gamerInfo.Uuid);
                RequestReceipts(listener);
                return(tcs.Task.TimeoutAfter(timeout).Result);
            });

            try
            {
                return(await task);
            }
            catch (Exception e)
            {
                Log(e.GetType().Name + ": " + e.Message);
            }
            return(_gamerInfo != null?ReceiptsListener.FromCache(_gamerInfo.Uuid) : null);
        }