private async Task <Listing> DeserializeCursor(DBCursor cursor, int count, Listing existing = null) { var targetListing = existing ?? new Listing { Data = new ListingData { Children = new List <Thing>() } }; int i = 0; if (cursor != null) { do { var currentRecord = cursor.Get(); var decodedListing = Encoding.UTF8.GetString(currentRecord, CommentKeySpaceSize, currentRecord.Length - CommentKeySpaceSize); var deserializedComment = JsonConvert.DeserializeObject <Thing>(decodedListing); targetListing.Data.Children.Add(deserializedComment); if (count == -1) { break; } } while (await cursor.MoveNextAsync()); } return(targetListing); }
private async Task <Listing> DeserializeCursor(DBCursor cursor, int count) { var redditService = ServiceLocator.Current.GetInstance <IRedditService>(); int i = 0; var targetListing = new Listing { Data = new ListingData { Children = new List <Thing>() } }; if (cursor != null) { do { var currentRecord = cursor.Get(); var decodedListing = Encoding.UTF8.GetString(currentRecord, LinkKeySpaceSize, currentRecord.Length - LinkKeySpaceSize); var deserializedLink = JsonConvert.DeserializeObject <Thing>(decodedListing); if (deserializedLink != null && deserializedLink.Data is Link) { redditService.AddFlairInfo(((Link)deserializedLink.Data).Name, ((Link)deserializedLink.Data).Author); } targetListing.Data.Children.Add(deserializedLink); if (i++ > count) { //after type encoding targetListing.Data.After = Encoding.UTF8.GetString(currentRecord, 0, 16); } }while(await cursor.MoveNextAsync()); } return(targetListing); }
private async Task<Listing> DeserializeCursor(DBCursor cursor, int count) { var redditService = ServiceLocator.Current.GetInstance<IRedditService>(); int i = 0; var targetListing = new Listing { Data = new ListingData { Children = new List<Thing>() } }; if(cursor != null) { do { var currentRecord = cursor.Get(); var decodedListing = Encoding.UTF8.GetString(currentRecord, LinkKeySpaceSize, currentRecord.Length - LinkKeySpaceSize); var deserializedLink = JsonConvert.DeserializeObject<Thing>(decodedListing); if (deserializedLink != null && deserializedLink.Data is Link) { redditService.AddFlairInfo(((Link)deserializedLink.Data).Name, ((Link)deserializedLink.Data).Author); } targetListing.Data.Children.Add(deserializedLink); if (i++ > count) { //after type encoding targetListing.Data.After = Encoding.UTF8.GetString(currentRecord, 0, 16); } }while(await cursor.MoveNextAsync()); } return targetListing; }