public void Set(StateUpdater <TState, TProps> calculateNewState) { if (calculateNewState == null) { throw new ArgumentNullException(nameof(calculateNewState)); } }
public ParamDelegates([NotNull] ValueGetter getter, [NotNull] ValueSetter setter, [CanBeNull] ValueValidator validator = null, [CanBeNull] StateUpdater updater = null) { Getter = getter ?? throw new ArgumentNullException(nameof(getter)); Setter = setter ?? throw new ArgumentNullException(nameof(setter)); Validator = validator; Updater = updater; }
public UserStreamsReceiver(TwitterAccount account) { _stateUpdater = new StateUpdater(); _handler = InitializeHandler(); _receiverTokenSource = new CancellationTokenSource(); _account = account; _cancellationTokenSource = null; ConnectionState = UserStreamsConnectionState.Disconnected; }
private async void AttachImageFromPath(string file) { var state = new StateUpdater(); try { state.UpdateState(InputAreaResources.StatusImageLoading); var bytes = await Task.Run(() => File.ReadAllBytes(file)); InputData.AttachedImages.Add(bytes); } catch (Exception ex) { ShowImageAttachErrorMessage(ex); } finally { state.UpdateState(); } }
public static async void GoToZone(Vector3Int nextZone, Direction dir) { List <Task> resetOps = new List <Task>(); // Fadeout screen // Save the state resetOps.Add(ResetScene()); resetOps.Add(StateUpdater.UpdateFiles()); // Delete all the stuff from the screen // TODO - Add all entities under a children or something and just recursively kill all entities // Also just do a quick clear tiles in the tilemaps // resetOps.Add(ResetScene()); await Task.WhenAll(resetOps); Debug.Log("Done unloading previous zone."); // Set the new zone to go var newZoneDelta = GameState.GetInstance()._PlayerState.currentZone - nextZone; GameState.GetInstance()._PlayerState.currentZone = nextZone; // Load the next zone ZoneState newZone = GetZone(nextZone); GameState.GetInstance()._ZoneState = newZone; Direction mirroredDir = (Direction)(((int)dir + 2) % 4); MovePlayer(Util.ToVector3(newZone.PortalInfo.Find(x => x.directionToGo == mirroredDir).entityInfo.pos)); Debug.Log("Loaded next zone"); // Load the zone to screen / this is done inside the ZoneState constructor // GG! Debug.Log("Current zone: " + nextZone); }
public UserStreamsReceiver(TwitterAccount account) { this._stateUpdater = new StateUpdater(); this._account = account; }
private MouseState(StateUpdater updateBehavior) { this.UpdateBehavior = updateBehavior; }
public async Task <string> Store(string expectedETag, TransactionalStateMetaData metadata, List <PendingTransactionState <TState> > statesToPrepare, long?commitUpTo, long?abortAfter) { if (_metadata.ETag != expectedETag) { throw new ArgumentException(nameof(expectedETag), "Etag does not match"); } var stateUpdater = new StateUpdater(_dbExecuter, _stateId, _options.StateTableName, _jsonSettings); // first, clean up aborted records if (abortAfter.HasValue && _states.Count != 0) { await stateUpdater.DeleteStates(afterSequenceId : abortAfter); while (_states.Count > 0 && _states[_states.Count - 1].SequenceId > abortAfter) { _states.RemoveAt(_states.Count - 1); } } // second, persist non-obsolete prepare records var obsoleteBefore = commitUpTo.HasValue ? commitUpTo.Value : _metadata.CommittedSequenceId; if (statesToPrepare != null && statesToPrepare.Count > 0) { foreach (var s in statesToPrepare) { if (s.SequenceId >= obsoleteBefore) { var newState = new TransactionStateEntity { SequenceId = s.SequenceId, TransactionId = s.TransactionId, Timestamp = s.TimeStamp, TransactionManager = s.TransactionManager, Value = s.State }; if (FindState(s.SequenceId, out var pos)) { // overwrite with new pending state _states[pos] = newState; await stateUpdater.UpdateState(newState).ConfigureAwait(false); } else { await stateUpdater.InsertState(newState).ConfigureAwait(false); _states.Insert(pos, newState); } _logger.LogTrace($"{_stateId}.{newState.SequenceId} Update {newState.TransactionId}"); } } } await stateUpdater.EnsureInsertBufferFlushed(); // third, persist metadata and commit position _metadata = await PersistMetadata(metadata, commitUpTo ?? _metadata.CommittedSequenceId); // fourth, remove obsolete records if (_states.Count > 0 && _states[0].SequenceId < obsoleteBefore) { FindState(obsoleteBefore, out var pos); await stateUpdater.DeleteStates(beforeSequenceId : obsoleteBefore); _states.RemoveRange(0, pos); } return(_metadata.ETag); }
public PresentedParameter([NotNull] IParameterDescriptor parameterDescriptor, [NotNull] UIElement element, [NotNull] ValueGetter getter, [NotNull] ValueSetter setter, [CanBeNull] ValueValidator validator = null, [CanBeNull] StateUpdater updater = null) : this(parameterDescriptor, element, new ParamDelegates(getter, setter, validator, updater)) { }