public static void EndUpdate(this IUpdateable updateable, System.Threading.CancellationToken token) { if (Common.IDisposedExtensions.IsNullOrDisposed(updateable)) { throw new System.ArgumentNullException(); //return default(System.Threading.CancellationToken); } //Ensure a token if (object.ReferenceEquals(token, null)) { return; } //That came from out cancellation source if (token.Equals(updateable.UpdateTokenSource.Token).Equals(false)) { throw InvalidStateException; } // check for manually removed state or a call without an update.. //if(m_Update.Wait(1, token)) { would check that the event was manually cleared... } // acknowledge cancellation if (token.IsCancellationRequested) { throw new System.OperationCanceledException(token); } //Allow threads to modify updateable.ManualResetEvent.Set(); //To unblocked }
public void RegisterUpdateableObject(IUpdateable obj) { if (!_updateableObjects.Contains(obj)) { _updateableObjects.Add(obj); } }
/// <summary> /// 根据条件更新实体信息(返回受影响行数) /// </summary> /// <param name="entity">实体</param> /// <param name="lstColumns">实体列</param> /// <param name="lstIgnoreColumns">忽略列</param> /// <param name="strWhere">条件</param> /// <returns></returns> public int UpdateEx(TEntity entity, List <string> lstColumns = null, List <string> lstIgnoreColumns = null, string strWhere = "") { int result = 0; try { _db.Ado.BeginTran(); IUpdateable <TEntity> up = _db.Updateable(entity); if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) { up = up.IgnoreColumns(lstIgnoreColumns.ToArray()); } if (lstColumns != null && lstColumns.Count > 0) { up = up.UpdateColumns(lstColumns.ToArray()); } if (!string.IsNullOrEmpty(strWhere)) { up = up.Where(strWhere); } result = up.ExecuteCommand(); _db.Ado.CommitTran(); } catch (Exception) { _db.Ado.RollbackTran(); } return(result); }
/// <summary> /// 根据条件更新实体信息(异步) /// </summary> /// <param name="entity">实体</param> /// <param name="lstColumns">实体列</param> /// <param name="lstIgnoreColumns">忽略列</param> /// <param name="strWhere">条件</param> /// <returns></returns> public async Task <bool> T_Update(TEntity entity, List <string> lstColumns = null, List <string> lstIgnoreColumns = null, string strWhere = "") { bool result = false; try { _db.Ado.BeginTran(); IUpdateable <TEntity> up = _db.Updateable(entity); if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) { up = up.IgnoreColumns(lstIgnoreColumns.ToArray()); } if (lstColumns != null && lstColumns.Count > 0) { up = up.UpdateColumns(lstColumns.ToArray()); } if (!string.IsNullOrEmpty(strWhere)) { up = up.Where(strWhere); } result = await up.ExecuteCommandHasChangeAsync(); _db.Ado.CommitTran(); } catch (Exception) { _db.Ado.RollbackTran(); } return(result); }
public void RemoveUpdatable(IUpdateable updatable, int updaterIndex) { if (updaterIndex > _updateables.Length || updaterIndex < 0) { UCLCore.Logger.LogError("", "updaterIndex out of bounds: " + updaterIndex); return; } // Eliminate multiple bounds checks var current = _updateables[updaterIndex]; if (current == null || current == updatable) { /* * We actually want to keep the largest, not the smallest. * If we kept the smallest we would need to search much farther * next time we need to add an updateable. */ _nextEstimatedSlot = Mathf.Max(updaterIndex, _nextEstimatedSlot); _updateables[updaterIndex] = null; } else { UCLCore.Logger.LogError("", "updatable not located at expected slot"); } }
public int AddUpdatable(IUpdateable updateable) { var index = -1; // First try to assign to known empty slot if (_updateables[_nextEstimatedSlot] == null) { _updateables[_nextEstimatedSlot] = updateable; index = _nextEstimatedSlot; _nextEstimatedSlot++; } else { // Otherwise check for first empty for (var i = 0; i < _updateables.Length; i++) { var u = _updateables[i]; if (u != null) { _updateables[i] = updateable; index = i; break; } } } if (index == -1) { UCLCore.Logger.LogError("", "No slots available for updateable"); } else { _highestFilledSlot = Mathf.Max(_highestFilledSlot, index); } return(index); }
public static void RegisterUpdateable(IUpdateable updateable) { if (!Updateables.Contains(updateable)) { Updateables.Add(updateable); } }
public void DeregisterUpdateableObject(IUpdateable obj) { if (_updateableObjects.Contains(obj)) { _updateableObjects.Remove(obj); } }
// constructor // main constructor method void buildInterface(IUpdateable parent, int pos_x, int pos_y, Texture texture) { Texture = texture; Parent = parent; Position_x = pos_x; Position_y = pos_y; }
/// <summary> /// Called when the component is enabled. /// </summary> protected virtual void OnEnable() { // interface references aren't serialized when unity hot-reloads if (Application.isEditor) { // ReSharper disable SuspiciousTypeConversion.Global if (_updateable == null) { _updateable = this as IUpdateable; } if (_lateUpdateable == null) { _lateUpdateable = this as ILateUpdateable; } if (_fixedUpdateable == null) { _fixedUpdateable = this as IFixedUpdateable; } // ReSharper restore SuspiciousTypeConversion.Global } // We don't want Update calls before Start has been called. if (_startWasCalled) { StartListening(); } }
public void Unregister(IUpdateable obj) { if (Instance.UpdateableObjects.Contains(obj)) { Instance.UpdateableObjects.Remove(obj); } }
public void Remove(IUpdateable updateable) { lock (m_Updateables) { m_Updateables.Remove(updateable); } }
public void Register(IUpdateable obj) { if (!Instance.UpdateableObjects.Contains(obj)) { Instance.UpdateableObjects.Add(obj); } }
public void RegisterObserver(IUpdateable observer) { if (!this.ObserverIsRegistered(observer)) { this.observers.Add(observer); } }
public void UnregisterObserver(IUpdateable observer) { if (this.ObserverIsRegistered(observer)) { this.observers.Remove(observer); } }
private void GameComponentAdded(object sender, GameComponentCollectionEventArgs e) { if (this.inRun) { e.GameComponent.Initialize(); } IUpdateable gameComponent = e.GameComponent as IUpdateable; if (gameComponent != null) { int num = this.updateableComponents.BinarySearch(gameComponent, UpdateOrderComparer.Default); if (num < 0) { this.updateableComponents.Insert(~num, gameComponent); gameComponent.UpdateOrderChanged += new EventHandler(this.UpdateableUpdateOrderChanged); } } IDrawable item = e.GameComponent as IDrawable; if (item != null) { int num2 = this.drawableComponents.BinarySearch(item, DrawOrderComparer.Default); if (num2 < 0) { this.drawableComponents.Insert(~num2, item); item.DrawOrderChanged += new EventHandler(this.DrawableDrawOrderChanged); } } }
public async Task <bool> Update(T entity, List <string> lstColumns = null, List <string> lstIgnoreColumns = null, string strWhere = "") { //IUpdateable<T> up = await Task.Run(() => _db.Updateable(entity)); //if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) //{ // up = await Task.Run(() => up.IgnoreColumns(it => lstIgnoreColumns.Contains(it))); //} //if (lstColumns != null && lstColumns.Count > 0) //{ // up = await Task.Run(() => up.UpdateColumns(it => lstColumns.Contains(it))); //} //if (!string.IsNullOrEmpty(strWhere)) //{ // up = await Task.Run(() => up.Where(strWhere)); //} //return await Task.Run(() => up.ExecuteCommand()) > 0; IUpdateable <T> up = Db.Updateable(entity); if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0) { up = up.IgnoreColumns(lstIgnoreColumns.ToArray()); } if (lstColumns != null && lstColumns.Count > 0) { up = up.UpdateColumns(lstColumns.ToArray()); } if (!string.IsNullOrEmpty(strWhere)) { up = up.Where(strWhere); } return(await up.ExecuteCommandHasChangeAsync()); }
/// <summary> /// Unsubscribes a IUpdateable from the game loop. /// </summary> /// <param name="updateable">The IUpdateable.</param> public void Unsubscribe(IUpdateable updateable) { if (_updateables.Contains(updateable)) { _updateables.Remove(updateable); } }
internal void Update(GameTime gameTime) { if (isClear) { return; } if (collectionsToUpdate.Count > 0) { CollectionUtils.Clear(collectionsToUpdate); } foreach (IGameComponent drawable in collections) { CollectionUtils.Add(collectionsToUpdate, drawable); } IGameComponent _drawable; int screenIndex; for (; collectionsToUpdate.Count > 0;) { screenIndex = collectionsToUpdate.Count - 1; _drawable = collectionsToUpdate[screenIndex]; CollectionUtils.RemoveAt(collectionsToUpdate, screenIndex); if (_drawable is IUpdateable) { IUpdateable comp = (IUpdateable)_drawable; comp.Update(gameTime); } } }
/// <summary> /// Subscribes a new IUpdateable to the game loop. /// </summary> /// <param name="updateable">The IUpdateable.</param> public void Subscribe(IUpdateable updateable) { if (!_updateables.Contains(updateable)) { _updateables.Add(updateable); } }
private void OnComponentRemoved( object sender, GameComponentCollectionEventArgs e ) { IUpdateable updateable = e.GameComponent as IUpdateable; if (updateable != null) { lock (updateableComponents) { updateableComponents.Remove(updateable); } updateable.UpdateOrderChanged -= OnUpdateOrderChanged; } IDrawable drawable = e.GameComponent as IDrawable; if (drawable != null) { lock (drawableComponents) { drawableComponents.Remove(drawable); } drawable.DrawOrderChanged -= OnDrawOrderChanged; } }
public static IUpdateable <T> Set <T, TV>( [NotNull] this IUpdateable <T> source, [NotNull] Expression <Func <T, TV> > extract, TV value) { if (source == null) { throw new ArgumentNullException("source"); } if (extract == null) { throw new ArgumentNullException("extract"); } var query = ((Updateable <T>)source).Query; query = query.Provider.CreateQuery <T>( Expression.Call( null, ((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(new[] { typeof(T), typeof(TV) }), new[] { query.Expression, Expression.Quote(extract), Expression.Constant(value, typeof(TV)) })); return(new Updateable <T> { Query = query }); }
public CensusStoreDataComparisonRow(string name, ICountableStore countService, ILocallyBackedStore localBackupService, IUpdateable refreshService) { Name = name; _countService = countService; _localBackupService = localBackupService; _refreshService = refreshService; IsRefreshable = true; }
/// <summary> /// Adds a member to the proxy /// </summary> public void Add(IUpdateable <T> member) { if (member == null) { return; } this.members.Add(member); }
public GameEngine(IUpdateable form) { TheSea = new Sea(); ViewModel = new ViewModel(this.TheSea, form); Turns = new List <Turn>(); CurrentTurn = new NoTurn(new List <BattleShip>(), TheSea, ViewModel); }
// TODO: add CancellationTokens public CensusStoreDataComparisonRow(string name, ILocallyBackedCensusStore locallyBackedCensusStore) { Name = name; _countService = locallyBackedCensusStore; _localBackupService = locallyBackedCensusStore; _refreshService = locallyBackedCensusStore; IsRefreshable = true; }
/// <summary> /// When the update order of a component in this manager changes, will need to find a new place for it /// on the list of updateable components. /// </summary> private void childUpdateOrderChanged(object sender, EventArgs e) { IUpdateable updatable = sender as IUpdateable; m_UpdateableComponents.Remove(updatable); insertSorted(updatable); }
public void AddUdateable(IUpdateable _updateable) { if (_updateable is Hero) { Hero hero = (Hero)_updateable; waitingForId.Enqueue(hero); SendMessage(new ClientHelloMessage()); } }
public void Subscribe(IUpdateable updateable, int priority) { toSubscribe.Add(new Data { Priorirty = priority, Updateable = updateable }); }
public Updater(IUpdateable applicationInfo) { this.applicationInfo = applicationInfo; this.bgWorker = new BackgroundWorker(); bgWorker.DoWork += BgWorker_DoWork; bgWorker.RunWorkerCompleted += BgWorker_RunWorkerCompleted; }
public static void ExecuteChunksLog <T>(this IUpdateable <T> sources, DeleteLogParametersEmbedded parameters, StringBuilder sb, CancellationToken cancellationToken) where T : Entity { WriteRows(sb, "Updating " + typeof(T).Name, () => sources.ExecuteChunks( parameters.ChunkSize, parameters.MaxChunks, pauseMilliseconds: parameters.PauseTime, cancellationToken: cancellationToken)); }
public static void Unregister(IUpdateable obj) { if (obj == null) { throw new System.ArgumentNullException(); } _table.Remove(obj); }
// --------------------------------------------------------------------- // Update // --------------------------------------------------------------------- public void Update <T>(T model, String statement, IUpdateable <T> traits) { using (IDbCommand command = m_connection.CreateCommand()) { command.CommandText = statement; traits.ApplyUpdate(model, command); command.ExecuteNonQuery(); } }
/// <summary> /// Initializes a new instance of the <see cref="Engine"/> class. /// </summary> /// <param name="commandHandler">IHandler object.</param> /// <param name="commandArguments">ICommandArguments object.</param> /// <param name="inputReader">IInputReader object.</param> /// <param name="turnUpdater">IUpdateable object.</param> public Engine( IHandler<ICommandArguments> commandHandler, ICommandArguments commandArguments, IInputReader inputReader, IUpdateable turnUpdater) { this.commandHandler = commandHandler; this.commandArguments = commandArguments; this.inputReader = inputReader; this.turnUpdater = turnUpdater; this.isRunning = false; }
public bool ObserverIsRegistered(IUpdateable observer) { return this.observers.Contains(observer); }
internal static UpdaterInternal GetUpdater(IUpdateable updateable) { if (!Updaters.ContainsKey(updateable)) Updaters.Add(updateable, new UpdaterInternal(updateable.XMLURL, updateable.UpdateURL, updateable.Version)); return Updaters[updateable]; }
public void AddUpdateableItem(IUpdateable item) { m_updateableItems.Add(item); }
public void RemoveUpdateableItem(IUpdateable item) { m_updateableItems.Remove(item); }
// all puzzle data public GameThread(IUpdateable obj) { updateObject = obj; }
/// <summary> /// Adds an object that can be updated to the scene. /// </summary> /// <param name="obj">The object to be added.</param> public void Add(IUpdateable obj) { _sceneUpdates.Add(obj); }
/// <summary> /// Remove an object that can be updated from the scene. /// </summary> /// <param name="obj">The object to be removed.</param> public void Remove(IUpdateable obj) { _sceneUpdates.Remove(obj); }
void AddUpdatable(IUpdateable u) { enabledUpdateable.Add(u); enabledUpdateable.Sort(UpdatableComparison); }
public void Unpause() { pausedException = null; delay = Utility.DELAY; Paused = false; foreach (IController c in controllerList) { c.Unpause(); } }
public void Pause(IUpdateable exception = null) { pausedException = exception; delay = Utility.DELAY; Paused = true; foreach (IController c in controllerList) { c.Pause(); } }
static int UpdatableComparison(IUpdateable x, IUpdateable y) { return x.UpdateOrder.CompareTo(y.UpdateOrder); }