Example #1
0
 private async Task <SubscriptionConnectionServerMessage> ReadNextObject(JsonTextReaderAsync jsonReader, bool waitForAck)
 {
     do
     {
         if ((_proccessingCts.IsCancellationRequested || _tcpClient.Connected == false) && waitForAck == false)
         {
             return(null);
         }
         jsonReader.ResetState();
     } while (await jsonReader.ReadAsync().ConfigureAwait(false) == false &&
              _proccessingCts.Token.IsCancellationRequested);// need to do that to handle the heartbeat whitespace
     if (_proccessingCts.Token.IsCancellationRequested && waitForAck == false)
     {
         return(null);
     }
     return((await RavenJObject.LoadAsync(jsonReader).ConfigureAwait(false)).JsonDeserialization <SubscriptionConnectionServerMessage>());
 }
Example #2
0
        public IEnumerable <Task> ParseJson()
        {
            string text = string.Format(@"{{
  ""AlbumArtUrl"": ""/Content/Images/placeholder.gif"",
  ""Genre"": {{
    ""Id"": ""genres/1"",
    ""Name"": ""Rock""
  }},
  ""Price"": 8.99,
  ""Title"": ""No More Tears (Remastered)"",
  ""CountSold"": 0,
  ""Artist"": {{
    ""Id"": ""artists/114"",
    ""Name"": ""Ozzy Osbourne""
  }}
}}");

            var reader = new JsonTextReaderAsync(new StringReader(text));
            var task   = RavenJObject.LoadAsync(reader);

            yield return(task);

            Assert.IsNotNull(task.Result);
        }