// Load the cached receipts from file and return the decrypted result.
 IList<Receipt> FromCache()
 {
     OuyaFacade.Log("Returning cached receipts");
     IList<Receipt> receipts = null;
     string encryptedReceipts = string.Empty;
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         if (store.FileExists(receiptsFileName))
         {
             using (var reader = new StreamReader(store.OpenFile(receiptsFileName, FileMode.Open)))
             {
                 encryptedReceipts = reader.ReadToEnd();
             }
         }
     }
     if (!string.IsNullOrEmpty(encryptedReceipts))
     {
         var decryptedReceipts = CryptoHelper.Decrypt(encryptedReceipts, _gamerUuid);
         var json = new JSONObject(decryptedReceipts);
         var list = json.OptJSONArray("receipts");
         if (list != null)
         {
             receipts = new List<Receipt>(list.Length());
             for (int i = 0; i < list.Length(); ++i)
             {
                 var node = list.GetJSONObject(i);
                 var identifier = node.GetString("identifier");
                 var priceInCents = node.GetInt("priceInCents");
                 var purchaseDate = new Java.Util.Date(node.GetString("purchaseDate"));
                 var generatedDate = new Java.Util.Date(node.GetString("generatedDate"));
                 var gamerUuid = node.GetString("gamerUuid");
                 var uuid = node.GetString("uuid");
                 var receipt = new Receipt(identifier, priceInCents, purchaseDate, generatedDate, gamerUuid, uuid);
                 receipts.Add(receipt);
             }
         }
     }
     return receipts;
 }
 // Load the cached receipts from file and return the decrypted result.
 internal static IList<Receipt> FromCache(string gamerUuid)
 {
     OuyaFacade.Log("Returning cached receipts");
     IList<Receipt> receipts = null;
     string encryptedReceipts = string.Empty;
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         if (store.FileExists(receiptsFileName))
         {
             using (var reader = new StreamReader(store.OpenFile(receiptsFileName, FileMode.Open)))
             {
                 encryptedReceipts = reader.ReadToEnd();
             }
         }
     }
     if (!string.IsNullOrEmpty(encryptedReceipts))
     {
         var decryptedReceipts = CryptoHelper.Decrypt(encryptedReceipts, gamerUuid);
         var json = new JSONObject(decryptedReceipts);
         var list = json.OptJSONArray("receipts");
         if (list != null)
         {
             receipts = new List<Receipt>(list.Length());
             for (int i = 0; i < list.Length(); ++i)
             {
                 var node = list.GetJSONObject(i);
                 var identifier = node.GetString("identifier");
                 var priceInCents = node.GetInt("priceInCents");
                 var purchaseDate = new Java.Util.Date(node.GetString("purchaseDate"));
                 var generatedDate = new Java.Util.Date(node.GetString("generatedDate"));
                 var gamer = node.GetString("gamerUuid");
                 var uuid = node.GetString("uuid");
                 // Cater for reading old receipts written with pre-1.0.8
                 double localPrice = priceInCents / 100.0;
                 string currencyCode = "USD";
                 try
                 {
                     localPrice = node.GetDouble("localPrice");
                     currencyCode = node.GetString("currencyCode");
                 }
                 catch (JSONException)
                 {
                     OuyaFacade.Log("Older receipt found. Assuming USD price.");
                 }
                 var receipt = new Receipt(identifier, priceInCents, purchaseDate, generatedDate, gamer, uuid, localPrice, currencyCode);
                 receipts.Add(receipt);
             }
         }
     }
     // Return an empty list if nothing was found
     if (receipts == null)
         receipts = new List<Receipt>();
     return receipts;
 }