public void SendCounterChanges(CounterChange change) { if (IsDisposed) { return; } if (_watchAllCounters > 0) { Send(change); return; } if (change.Name != null && _matchingCounters.Contains(change.Name)) { Send(change); return; } if (change.DocumentId != null && _matchingDocumentCounters.Contains(change.DocumentId)) { Send(change); return; } if (change.DocumentId != null && change.Name != null && _matchingDocumentCounter.Count > 0) { var parameters = new DocumentIdAndNamePair(change.DocumentId, change.Name); if (_matchingDocumentCounter.Contains(parameters)) { Send(change); return; } } }
private void CounterButtonClick(object sender, EventArgs e) { var view = sender as View; switch (view.Id) { case Resource.Id.SubtractCountButton: CounterItem.Count--; break; case Resource.Id.AddCountButton: CounterItem.Count++; break; case Resource.Id.SubtractTenCountButton: CounterItem.Count -= 10; break; case Resource.Id.AddTenCountButton: CounterItem.Count += 10; break; } SetCounterItem(CounterItem); CounterChange?.Invoke(CounterItem, AdapterPosition); }
private void NotifyAboutWork(DocumentChange documentChange, CounterChange counterChange) { // ReSharper disable once ForCanBeConvertedToForeach for (var i = 0; i < _processes.Length; i++) { _processes[i].NotifyAboutWork(documentChange, counterChange); } }
public void AddAfterCommitNotification(CounterChange change) { change.TriggeredByReplicationThread = IncomingReplicationHandler.IsIncomingReplication; if (_counterNotifications == null) { _counterNotifications = new List <CounterChange>(); } _counterNotifications.Add(change); }
public void RaiseNotifications(CounterChange counterChange) { OnCounterChange?.Invoke(counterChange); foreach (var connection in Connections) { if (!connection.Value.IsDisposed) { connection.Value.SendCounterChanges(counterChange); } } }
private bool AssertCounterChange(CounterChange counterChange, string docId, string counterName, long?val = null) { if (counterChange.DocumentId != docId) { ReportFailure($"Got the wrong counter change. Subscribed to counter changes for document '{docId}' " + $"but got counter change for document '{counterChange.DocumentId}'. Aborting", null); return(false); } if (val == null) { if (counterChange.Type != CounterChangeTypes.Increment && counterChange.Type != CounterChangeTypes.Put) { ReportFailure("Got the wrong counter change type. " + "Expected 'CounterChangeTypes.Increment' or 'CounterChangeTypes.Put' " + $"but got : '{counterChange.Type}'. Aborting", null); return(false); } } else { if (counterChange.Type != CounterChangeTypes.Increment) { ReportFailure("Got the wrong counter change type. " + $"Expected 'CounterChangeTypes.Increment' but got : '{counterChange.Type}'. Aborting", null); return(false); } } if (counterChange.Name != counterName) { ReportFailure("Got wrong counter change. " + $"Subscribed to counter changes for counter '{counterName}' " + $"but got counter change for : '{counterChange.Name}'. Aborting", null); return(false); } if (val != null && val >= counterChange.Value) { ReportFailure("Got wrong counter-change value. " + "Expected old value < counter-change value but got : " + $"old value : '{val}', counter-change value: '{counterChange.Value}'. Aborting", null); return(false); } return(true); }
private void Send(CounterChange change) { var value = new DynamicJsonValue { ["Type"] = nameof(CounterChange), ["Value"] = change.ToJson() }; if (_disposeToken.IsCancellationRequested == false) { _sendQueue.Enqueue(new ChangeValue { ValueToSend = value, AllowSkip = true }); } }
private void OnCounterChange(CounterChange change) { NotifyAboutWork(documentChange: null, counterChange: change); }
private void OnCounterChange(CounterChange change) { OnChangeInternal(change.TriggeredByReplicationThread); }
private void OnCounterChange(CounterItem item, int postion) { CounterChange?.Invoke(item, postion); }
public abstract void NotifyAboutWork(DocumentChange documentChange, CounterChange counterChange);