public void Entity_to_value_test() { var a = new StringEntity("a"); var b = new StringEntity("b"); var c = new StringEntity("c"); var d = new StringEntity("d"); var e = new StringEntity("e"); a.ValueEntities() .Select(x => x.ToString()) .Should() .BeEquivalentTo("a"); (a * b * c * d * e).ValueEntities() .Select(x => x.ToString()) .Should() .BeEquivalentTo("a", "b", "c", "d", "e"); (a + b + c + d + e).ValueEntities() .Select(x => x.ToString()) .Should() .BeEquivalentTo("a", "b", "c", "d", "e"); (a + b + c + d * e).ValueEntities() .Select(x => x.ToString()) .Should() .BeEquivalentTo("a", "b", "c", "d", "e"); }
public void ItShouldConsiderSameInstanceEqual() { var entity1 = new StringEntity(); var entity2 = entity1; entity1.Should().Be(entity2); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public String call() throws java.io.IOException public override string call() { HttpPost request = new HttpPost(outerInstance.APP_BASE_PATH + FETCH_AND_LOCK_PATH); request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); StringEntity stringEntity = new StringEntity("{ \"workerId\": \"aWorkerId\", \"asyncResponseTimeout\": 1000 }"); request.Entity = stringEntity; CloseableHttpResponse response = httpClient.execute(request, HttpClientContext.create()); string responseBody = null; try { HttpEntity entity = response.Entity; responseBody = EntityUtils.ToString(entity); request.releaseConnection(); } finally { response.close(); } return(responseBody); }
private void CheckCollections() { Assert.AreEqual(str_native.Length, str_list.Count); int elem_len = math.min(str_native.Length, str_list.Count); for (int i = 0; i < elem_len; i++) { StringEntity entity = str_native[i]; string str_e = entity.ToString(); char[] c_arr_e = entity.ToArray(); ReadOnlyStringEntity entity_ro = entity.GetReadOnly(); string str = str_list[i]; char[] c_arr = str.ToCharArray(); Assert.AreEqual(str_e, str); Assert.AreEqual(c_arr_e.ToString(), c_arr.ToString()); Assert.IsTrue(entity.Equals(str)); Assert.IsTrue(entity.Equals(c_arr)); if (str.Length == 1) { Assert.IsTrue(entity.Equals(str[0])); } Assert.IsTrue(entity_ro.Equals(str)); Assert.IsTrue(entity_ro.Equals(c_arr)); if (str.Length == 1) { Assert.IsTrue(entity_ro.Equals(str[0])); } } }
public void CheckAPI_ReallocateTracer() { #if ENABLE_UNITY_COLLECTIONS_CHECKS string str = "1234567890--@@"; var NSL = new NativeStringList(Allocator.TempJob); NSL.Add(str); StringEntity entity = NSL[0]; bool effective_ref = true; for (int i = 0; i < 100; i++) { NSL.Add(str); try { Debug.Log($"add: {i}, entity: {entity.ToString()}, NSL [Size/Capacity] = [{NSL.Size}/{NSL.Capacity}]"); } catch (InvalidOperationException e) { effective_ref = false; Debug.Log("the reallocation of NativeStringList is detected by StringEntity. exception: " + e.Message); break; } } Assert.IsFalse(effective_ref); NSL.Dispose(); #else Debug.Log("this feature will be enabled when the macro 'ENABLE_UNITY_COLLECTIONS_CHECKS' is defined."); Debug.Log("it is not tested in current setting."); #endif }
public override void Run() { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response; string responseString = null; try { HttpPut post = new HttpPut(pathToDoc1.ToExternalForm()); StringEntity se = new StringEntity(docJson.ToString()); se.SetContentType(new BasicHeader("content_type", "application/json")); post.SetEntity(se); response = httpclient.Execute(post); StatusLine statusLine = response.GetStatusLine(); Log.D(Test7_PullReplication.Tag, "Got response: " + statusLine); NUnit.Framework.Assert.IsTrue(statusLine.GetStatusCode() == HttpStatus.ScCreated); } catch (ClientProtocolException e) { NUnit.Framework.Assert.IsNull("Got ClientProtocolException: " + e.GetLocalizedMessage (), e); } catch (IOException e) { NUnit.Framework.Assert.IsNull("Got IOException: " + e.GetLocalizedMessage(), e); } httpRequestDoneSignal.CountDown(); }
public void Multi_Type_Entity_Test() { var intEntity = new IntEntity() { Id = 1 }; var longEntity = new LongEntity() { Id = 1 }; var stringEntity = new StringEntity() { Id = "A" }; var guidEntity = new GuidEntity() { Id = new Guid() }; var userEntity = new UserEntity() { Id = { No = 1, Code = "AA" } }; Assert.NotNull(intEntity); Assert.NotNull(longEntity); Assert.NotNull(stringEntity); Assert.NotNull(guidEntity); Assert.NotNull(userEntity); }
/// <summary> /// 更新标题 /// </summary> /// <param name="Title">标题</param> /// <returns></returns> public async System.Threading.Tasks.Task <bool> UpdateWithTitle(StringEntity Title) { if (IsEmpty()) { return(false); } entity.Title = Title; return(await Update()); }
/// <summary> /// 更新介绍 /// </summary> /// <param name="Introduce">介绍</param> /// <returns></returns> public async System.Threading.Tasks.Task <bool> UpdateWithIntroduce(StringEntity Introduce) { if (IsEmpty()) { return(false); } entity.Introduce = Introduce; return(await Update()); }
/// <summary> /// 更新内容 /// </summary> /// <param name="Content">内容</param> /// <returns></returns> public async System.Threading.Tasks.Task <bool> UpdateWithContent(StringEntity Content) { if (IsEmpty()) { return(false); } entity.Content = Content; return(await Update()); }
/// <summary> /// 处理函数 /// </summary> /// <param name="serviceProvider">依赖注入接口</param> /// <param name="ContentId">内容id</param> /// <param name="Title">标题</param> /// <param name="Image">首图</param> /// <param name="Content">内容</param> /// <param name="Status">状态 0:未审核 1:审核通过 2:拒绝</param> /// <param name="Updated">更新时间</param> /// <param name="CreateUid">创建用户</param> /// <param name="CreateIP">建立IP</param> /// <param name="CreateDate">建立时间</param> /// <param name="Introduce">介绍</param> public static async System.Threading.Tasks.Task <ContentContext> Sub( IServiceProvider serviceProvider, GuidEntity ContentId , StringEntity Title , StringEntity Image , StringEntity Content , short Status , System.DateTime Updated , GuidEntity CreateUid , StringEntity CreateIP , System.DateTime CreateDate , StringEntity Introduce ) { ContentContext operinfo = await GetInfo(serviceProvider, ContentId); if (operinfo.IsEmpty()) { Culture.Entity.CL_Content info = new Culture.Entity.CL_Content { ContentId = operinfo.CreateGuid(), Title = Title, Image = Image, Content = Content, Status = Status, Recycle = 0, Updated = Updated, CreateUid = CreateUid, CreateIP = CreateIP, CreateDate = CreateDate, Introduce = Introduce, }; operinfo.SetEntity(info); if (!await operinfo.Insert()) { throw new System.Exception("添加失败!"); } } else { operinfo.GetEntity().Title = Title; operinfo.GetEntity().Image = Image; operinfo.GetEntity().Content = Content; operinfo.GetEntity().Status = Status; operinfo.GetEntity().Updated = Updated; operinfo.GetEntity().CreateUid = CreateUid; operinfo.GetEntity().CreateIP = CreateIP; operinfo.GetEntity().CreateDate = CreateDate; operinfo.GetEntity().Introduce = Introduce; if (!await operinfo.Update()) { throw new System.Exception("更改失败!"); } } return(operinfo); }
public void GetHashCode_ReferenceIdNull() { var e1 = new StringEntity(); var dic = new Dictionary <StringEntity, string>(); dic.Add(e1, string.Empty); var a = dic[e1]; Assert.Equal(a, string.Empty); }
/// <summary> /// 根据状态获取信息列表 /// </summary> /// <param name="serviceProvider"></param> /// <param name="page"></param> /// <param name="name"></param> /// <returns></returns> public static async System.Threading.Tasks.Task <List <ContentContext> > GetListPageLikeName( IServiceProvider serviceProvider, PageInfo page, StringEntity name) { Culture.BusyData.Content db = new Culture.BusyData.Content(serviceProvider); return(await TransList( db.GetListPageLikeName(page, name), t => { return new ContentContext(serviceProvider, t, db); })); }
public void Entity_operator_overload_test() { var a = new StringEntity("a"); var b = new StringEntity("b"); var c = new StringEntity("c"); (a + b + c).ToString().Should().Be("a + b + c"); (a * b * c).ToString().Should().Be("a * b * c"); (a + b * c).ToString().Should().Be("a + b * c"); ((a + b) * c).ToString().Should().Be("(a + b) * c"); }
/// <summary> /// 根据分页参数获取数据列表 /// </summary> /// <param name="page">分页信息</param> /// <param name="name">搜索关键字</param> /// <returns></returns> public async System.Threading.Tasks.Task <List <CL_Content> > GetListPageLikeName( PageInfo page, StringEntity name) { return(await QueryListPage( $"{ReName($"{Prefix}Content")}", $"GetListPageLikeName:{name}", DataReader, page, $" ({ReName("Title")} like '%{name}%' OR {ReName("Content")} like '%{name}%' OR {ReName("Introduce")} like '%{name}%' ) AND {Recycle()} AND {ReName("Status")} = 1 ")); }
public void ItShouldConsiderSameDefaultIdentityNotEqualViaUnequalOperator() { var entity1 = new StringEntity { Id = null }; var entity2 = new StringEntity { Id = null }; (entity1 != entity2).Should().BeTrue(); }
public void ItShouldConsiderSameDefaultIdentityNotEqual() { var entity1 = new StringEntity { Id = null }; var entity2 = new StringEntity { Id = null }; entity1.Should().NotBe(entity2); }
public void ItShouldNotConsiderDifferentIdentityEqualViaUnequalOperator() { var entity1 = new StringEntity { Id = "12345" }; var entity2 = new StringEntity { Id = "qwert" }; (entity1 != entity2).Should().BeTrue(); }
public void ItShouldNotConsiderDifferentIdentityEqual() { var entity1 = new StringEntity { Id = "12345" }; var entity2 = new StringEntity { Id = "qwert" }; entity1.Should().NotBe(entity2); }
public void Should_deserialize_from_guid_string() { var id = Guid.NewGuid(); var source = new StringEntity <Guid> { Id = id }; var result = SerializeAndDeserializeBson <StringEntity <Guid>, IdEntity <DomainId> >(source); Assert.Equal(result.Id.ToString(), id.ToString()); }
public void ItShouldConsiderSameNonDefaultIdentityEqualViaUnequalOperator() { var identity = "1234qwerasdf"; var entity1 = new StringEntity { Id = identity }; var entity2 = new StringEntity { Id = identity }; (entity1 != entity2).Should().BeFalse(); }
public void ItShouldConsiderSameNonDefaultIdentityEqual() { var identity = "1234qwerasdf"; var entity1 = new StringEntity { Id = identity }; var entity2 = new StringEntity { Id = identity }; entity1.Should().Be(entity2); }
public void TestSaveStringEntity() { StringEntity entity = new StringEntity { StringField = "foobar" }; StringEntity savedEntity = Backendless.Persistence.Save(entity); Assert.IsNotNull(savedEntity, "Server returned a null result"); Assert.IsNotNull(savedEntity.StringField, "Returned object doesn't have expected field"); Assert.IsNotNull(savedEntity.ObjectId, "Returned object doesn't have expected field id"); Assert.IsNotNull(savedEntity.Created, "Returned object doesn't have expected field created"); Assert.AreEqual(entity.StringField, savedEntity.StringField, "Returned object has wrong field value"); }
public void OneTimeSetUp() { this.str_source = " 1234567890@@0987654321^^ 1234567\t890 # "; this.NL_source = new NativeList <Char16>(Allocator.TempJob); foreach (Char16 c in str_source) { NL_source.Add(c); } this.SE_source = NL_source.ToStringEntity(); this.ref_list = new List <string>(); this.NSL_result = new NativeStringList(Allocator.TempJob); this.NL_SE_result = new NativeList <StringEntity>(Allocator.TempJob); }
/// <summary> /// 处理函数 /// </summary> /// <param name="serviceProvider">依赖注入接口</param> /// <param name="CommID">评论id</param> /// <param name="ContentId">内容id</param> /// <param name="Content">内容</param> /// <param name="Updated">更新时间</param> /// <param name="CreateUid">创建用户</param> /// <param name="CreateIP">建立IP</param> /// <param name="CreateDate">建立时间</param> public static async System.Threading.Tasks.Task <CommContext> Sub( IServiceProvider serviceProvider, GuidEntity CommID , GuidEntity ContentId , StringEntity Content , System.DateTime Updated , GuidEntity CreateUid , StringEntity CreateIP , System.DateTime CreateDate ) { CommContext operinfo = await GetInfo(serviceProvider, CommID); if (operinfo.IsEmpty()) { Culture.Entity.CL_Comm info = new Culture.Entity.CL_Comm { CommID = operinfo.CreateGuid(), ContentId = ContentId, Content = Content, Recycle = 0, Updated = Updated, CreateUid = CreateUid, CreateIP = CreateIP, CreateDate = CreateDate, }; operinfo.SetEntity(info); if (!await operinfo.Insert()) { throw new System.Exception("添加失败!"); } } else { operinfo.GetEntity().ContentId = ContentId; operinfo.GetEntity().Content = Content; operinfo.GetEntity().Updated = Updated; operinfo.GetEntity().CreateUid = CreateUid; operinfo.GetEntity().CreateIP = CreateIP; operinfo.GetEntity().CreateDate = CreateDate; if (!await operinfo.Update()) { throw new System.Exception("更改失败!"); } } return(operinfo); }
private void ApplyRemoveAt(int n_RemoveAt) { if (str_native.Length <= 0 || str_list.Count <= 0) { return; } if (n_RemoveAt <= 0) { return; } Assert.AreEqual(str_native.Length, str_list.Count); int i_range = str_native.Length; int n_remove = math.min(n_RemoveAt, i_range); Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (before remove)"); for (int i = 0; i < n_remove; i++) { int index = random.Next(0, i_range); StringEntity entity = str_native.At(index); ReadOnlyStringEntity entity_ro = entity.GetReadOnly(); //Debug.Log("delete: index = " + index.ToString()); str_native.RemoveAt(index); str_list.RemoveAt(index); i_range--; } Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (after remove)"); str_native.ReAdjustment(); Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (after call 'ReAdjustment()')"); str_native.ShrinkToFit(); Debug.Log("str_native.Capacity = " + str_native.Capacity.ToString() + ", str_native.Size = " + str_native.Size.ToString() + ", str_native.IndexCapacity = " + str_native.IndexCapacity.ToString() + ", str_native.Length = " + str_native.Length.ToString() + " (after call 'ShrinkToFit()')"); }
public void StringEntitySerializing() { var serializer = new SerializerConfig().Create(); var input = new StringEntity { Name = Encoding.UTF8.GetString(new byte[] { 1, 2, 3, 4, 5 }) }; using (var stream = CreateStream()) { serializer.Serialize(stream, input); stream.Seek(0); var result = serializer.Deserialize <StringEntity>(stream); Assert.NotNull(result); Assert.Equal(input.Name, result.Name); } }
public void Entity_symplify_test() { var a = new StringEntity("a"); var b = new StringEntity("b"); var c = new StringEntity("c"); var d = new StringEntity("d"); var e = new StringEntity("e"); (a + b + c + d + e).Simplify().ToString().Should().Be("a + b + c + d + e"); ((a + b) + (c + d) + e).Simplify().ToString().Should().Be("a + b + c + d + e"); (a * b * c * d * e).Simplify().ToString().Should().Be("a * b * c * d * e"); ((a * b) * c * (d * e)).Simplify().ToString().Should().Be("a * b * c * d * e"); (a * (b + c + d * e)).Simplify().ToString().Should().Be("a * b + a * c + a * d * e"); (a * (b + c * d)).Simplify().ToString().Should().Be("a * b + a * c * d"); ((a + b) * (c + d)).Simplify().ToString().Should().Be("a * c + a * d + b * c + b * d"); (a * (b + c) * (d + e)).Simplify().ToString().Should().Be("a * b * d + a * b * e + a * c * d + a * c * e"); ((a + b + c + d * e) * e).Simplify().ToString().Should().Be("a * e + b * e + c * e + d * e * e"); ((a + b + c) * (b + c + d) * (d + e)).Simplify().ToString().Should().Be("a * b * d + a * c * d + b * b * d + b * c * d + a * d * d + b * d * d + c * b * d + c * c * d + a * b * e + a * c * e + b * b * e + b * c * e + a * d * e + b * d * e + c * b * e + c * c * e + c * d * d + c * d * e"); }
public void StripBySingleChar() { str_source = "@@%%@ test\tstring @+<>@@@"; ref_Lstrip = "%%@ test\tstring @+<>@@@"; ref_Rstrip = "@@%%@ test\tstring @+<>"; ref_Strip = "%%@ test\tstring @+<>"; char c_target = '@'; NL_source.Clear(); foreach (char c in str_source) { NL_source.Add(c); } SE_source = NL_source.ToStringEntity(); Debug.Log(" >> try NativeList<char>.Lstrip(char, result) >>"); NL_source.Lstrip(c_target, NL_result); Assert.IsTrue(this.CheckStripperResult(NL_result, ref_Lstrip)); Debug.Log(" >> try result = StringEntity.Lstrip(char) >>"); SE_result = SE_source.Lstrip(c_target); Assert.IsTrue(this.CheckStripperResult(SE_result, ref_Lstrip)); Debug.Log(" >> try NativeList<char>.Rstrip(char, result) >>"); NL_source.Rstrip(c_target, NL_result); Assert.IsTrue(this.CheckStripperResult(NL_result, ref_Rstrip)); Debug.Log(" >> try result = StringEntity.Rstrip(char) >>"); SE_result = SE_source.Rstrip(c_target); Assert.IsTrue(this.CheckStripperResult(SE_result, ref_Rstrip)); Debug.Log(" >> try NativeList<char>.Strip(char, result) >>"); NL_source.Strip(c_target, NL_result); Assert.IsTrue(this.CheckStripperResult(NL_result, ref_Strip)); Debug.Log(" >> try result = StringEntity.Strip(char) >>"); SE_result = SE_source.Strip(c_target); Assert.IsTrue(this.CheckStripperResult(SE_result, ref_Strip)); }
public void TestFindRecordById() { StringEntity entity = new StringEntity(); entity.StringField = "foobar"; StringEntity savedEntity = Backendless.Persistence.Save(entity); Assert.IsNotNull(savedEntity, "Server returned a null result"); Assert.IsNotNull(savedEntity.StringField, "Returned object doesn't have expected field"); Assert.IsNotNull(savedEntity.ObjectId, "Returned object doesn't have expected field id"); Assert.IsNotNull(savedEntity.Created, "Returned object doesn't have expected field created"); Assert.AreEqual(entity.StringField, savedEntity.StringField, "Returned object has wrong field value"); var foundEntity = Backendless.Persistence.Of <StringEntity>().FindById(savedEntity.ObjectId); Assert.AreEqual(savedEntity.Created, foundEntity.Created, "Found object contain wrong created date"); Assert.AreEqual(savedEntity.ObjectId, foundEntity.ObjectId, "Found object contain wrong objectId"); Assert.AreEqual(savedEntity.StringField, foundEntity.StringField, "Found object contain wrong field value"); }
public override void Run() { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response; string responseString = null; try { HttpPut post = new HttpPut(pathToDoc1.ToExternalForm()); StringEntity se = new StringEntity(docJson.ToString()); se.SetContentType(new BasicHeader("content_type", "application/json")); post.SetEntity(se); response = httpclient.Execute(post); StatusLine statusLine = response.GetStatusLine(); Log.D(ReplicationTest.Tag, "Got response: " + statusLine); NUnit.Framework.Assert.IsTrue(statusLine.GetStatusCode() == HttpStatus.ScCreated); } catch (ClientProtocolException e) { NUnit.Framework.Assert.IsNull("Got ClientProtocolException: " + e.GetLocalizedMessage (), e); } catch (IOException e) { NUnit.Framework.Assert.IsNull("Got IOException: " + e.GetLocalizedMessage(), e); } httpRequestDoneSignal.CountDown(); }
public virtual void Run() { running = true; HttpClient httpClient; if (client == null) { // This is a race condition that can be reproduced by calling cbpuller.start() and cbpuller.stop() // directly afterwards. What happens is that by the time the Changetracker thread fires up, // the cbpuller has already set this.client to null. See issue #109 Log.W(Log.TagChangeTracker, "%s: ChangeTracker run() loop aborting because client == null" , this); return; } if (mode == ChangeTracker.ChangeTrackerMode.Continuous) { // there is a failing unit test for this, and from looking at the code the Replication // object will never use Continuous mode anyway. Explicitly prevent its use until // it is demonstrated to actually work. throw new RuntimeException("ChangeTracker does not correctly support continuous mode" ); } httpClient = client.GetHttpClient(); backoff = new ChangeTrackerBackoff(); while (running) { Uri url = GetChangesFeedURL(); if (usePOST) { HttpPost postRequest = new HttpPost(url.ToString()); postRequest.SetHeader("Content-Type", "application/json"); StringEntity entity; try { entity = new StringEntity(ChangesFeedPOSTBody()); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } postRequest.SetEntity(entity); request = postRequest; } else { request = new HttpGet(url.ToString()); } AddRequestHeaders(request); // Perform BASIC Authentication if needed bool isUrlBasedUserInfo = false; // If the URL contains user info AND if this a DefaultHttpClient then preemptively set the auth credentials string userInfo = url.GetUserInfo(); if (userInfo != null) { isUrlBasedUserInfo = true; } else { if (authenticator != null) { AuthenticatorImpl auth = (AuthenticatorImpl)authenticator; userInfo = auth.AuthUserInfo(); } } if (userInfo != null) { if (userInfo.Contains(":") && !userInfo.Trim().Equals(":")) { string[] userInfoElements = userInfo.Split(":"); string username = isUrlBasedUserInfo ? URIUtils.Decode(userInfoElements[0]) : userInfoElements [0]; string password = isUrlBasedUserInfo ? URIUtils.Decode(userInfoElements[1]) : userInfoElements [1]; Credentials credentials = new UsernamePasswordCredentials(username, password); if (httpClient is DefaultHttpClient) { DefaultHttpClient dhc = (DefaultHttpClient)httpClient; MessageProcessingHandler preemptiveAuth = new _MessageProcessingHandler_285(credentials ); dhc.AddRequestInterceptor(preemptiveAuth, 0); } } else { Log.W(Log.TagChangeTracker, "RemoteRequest Unable to parse user info, not setting credentials" ); } } try { string maskedRemoteWithoutCredentials = GetChangesFeedURL().ToString(); maskedRemoteWithoutCredentials = maskedRemoteWithoutCredentials.ReplaceAll("://.*:.*@" , "://---:---@"); Log.V(Log.TagChangeTracker, "%s: Making request to %s", this, maskedRemoteWithoutCredentials ); HttpResponse response = httpClient.Execute(request); StatusLine status = response.GetStatusLine(); if (status.GetStatusCode() >= 300 && !Utils.IsTransientError(status)) { Log.E(Log.TagChangeTracker, "%s: Change tracker got error %d", this, status.GetStatusCode ()); this.error = new HttpResponseException(status.GetStatusCode(), status.GetReasonPhrase ()); Stop(); } HttpEntity entity = response.GetEntity(); InputStream input = null; if (entity != null) { try { input = entity.GetContent(); if (mode == ChangeTracker.ChangeTrackerMode.LongPoll) { // continuous replications IDictionary<string, object> fullBody = Manager.GetObjectMapper().ReadValue<IDictionary >(input); bool responseOK = ReceivedPollResponse(fullBody); if (mode == ChangeTracker.ChangeTrackerMode.LongPoll && responseOK) { Log.V(Log.TagChangeTracker, "%s: Starting new longpoll", this); backoff.ResetBackoff(); continue; } else { Log.W(Log.TagChangeTracker, "%s: Change tracker calling stop (LongPoll)", this); Stop(); } } else { // one-shot replications JsonFactory jsonFactory = Manager.GetObjectMapper().GetJsonFactory(); JsonParser jp = jsonFactory.CreateJsonParser(input); while (jp.NextToken() != JsonToken.StartArray) { } // ignore these tokens while (jp.NextToken() == JsonToken.StartObject) { IDictionary<string, object> change = (IDictionary)Manager.GetObjectMapper().ReadValue <IDictionary>(jp); if (!ReceivedChange(change)) { Log.W(Log.TagChangeTracker, "Received unparseable change line from server: %s", change ); } } Log.W(Log.TagChangeTracker, "%s: Change tracker calling stop (OneShot)", this); Stop(); break; } backoff.ResetBackoff(); } finally { try { entity.ConsumeContent(); } catch (IOException) { } } } } catch (Exception e) { if (!running && e is IOException) { } else { // in this case, just silently absorb the exception because it // frequently happens when we're shutting down and have to // close the socket underneath our read. Log.E(Log.TagChangeTracker, this + ": Exception in change tracker", e); } backoff.SleepAppropriateAmountOfTime(); } } Log.V(Log.TagChangeTracker, "%s: Change tracker run loop exiting", this); }