private async Task <int?> PushCoreAsync() { if (_familyId == null) { throw new InvalidOperationException("No familyId has been specified; the service must be initialized first with a valid familyId."); } var pushRequest = Dto.pushRequest(State); if (pushRequest.IsSome()) { var pushResponse = await _cosmos.PushAsync(_familyId, pushRequest.Value); var import = Dto.changesAsImport(pushResponse); if (import.IsSome()) { var message = StateTypes.StateMessage.NewImport(import.Value); State = StateModule.updateUsingStandardClock(message, State); OnChange?.Invoke(); return(import.Value.EarliestTimestamp.AsNullable()); } else { return(null); } } else { return(null); } }
private async Task <int?> PushCoreAsync() { var pushRequest = Dto.pushRequest(State); if (pushRequest.IsSome()) { var pushResponse = await _cosmos.PushAsync(FamilyIdModule.serialize(State !.FamilyId), pushRequest.Value); var import = Dto.changesAsImport(pushResponse); if (import.IsSome()) { var message = StateTypes.StateMessage.NewImport(import.Value); State = StateModule.updateUsingStandardClock(message, State); OnChange?.Invoke(); return(import.Value.EarliestTimestamp.AsNullable()); } else { return(null); } } else { return(null); } }
public async Task UpdateAsync(StateTypes.StateMessage message) { if (State == null) { throw new InvalidOperationException("Can not start synchronizing until the service is initialized."); } State = StateModule.updateUsingStandardClock(message, State); OnChange?.Invoke(); if (StateModule.hasChanges(State)) { await SyncCoreAsync(isIncremental : true, ignoreIfSynchronizing : false); } }
private async Task PullCoreAsync(int?after, int?before) { var pullResponse = (after is null && before is null) ? await _cosmos.PullEverythingAsync(FamilyIdModule.serialize(State !.FamilyId)) : await _cosmos.PullIncrementalAsync(FamilyIdModule.serialize(State !.FamilyId), after ?? int.MinValue, before); var import = Dto.changesAsImport(pullResponse); if (import.IsSome()) { var message = StateTypes.StateMessage.NewImport(import.Value); State = StateModule.updateUsingStandardClock(message, State); OnChange?.Invoke(); } }
private async Task PullCoreAsync(int?after, int?before) { if (_familyId == null) { throw new InvalidOperationException("No familyId has been specified; the service must be initialized first with a valid familyId."); } var pullResponse = (after is null && before is null) ? await _cosmos.PullEverythingAsync(_familyId) : await _cosmos.PullIncrementalAsync(_familyId, after ?? int.MinValue, before); var import = Dto.changesAsImport(pullResponse); if (import.IsSome()) { var message = StateTypes.StateMessage.NewImport(import.Value); State = StateModule.updateUsingStandardClock(message, State); OnChange?.Invoke(); } }
public async Task UpdateAsync(StateTypes.StateMessage message) { State = StateModule.updateUsingStandardClock(message, State); OnChange?.Invoke(); await SyncCoreAsync(isIncremental : true, ignoreIfSynchronizing : false); }