public ClockHandler RegisterActionAtTime(ulong delta_time, ClockAction action) { Contract.Requires <ArgumentNullException> (action != null); Contract.Ensures ((Contract.Result <ClockHandler> () != null && delta_time != 0) || Contract.Result <ClockHandler> () == null); return default (ClockHandler); }
public ClockHandler RegisterConditionalAction(Func <bool> condition, ClockAction action) { Contract.Requires <ArgumentNullException> (condition != null); Contract.Requires <ArgumentNullException> (action != null); Contract.Ensures (Contract.Result <ClockHandler> () != null); return default (ClockHandler); }
public ClockHandler RegisterAction(ulong tick, ClockAction action) { Contract.Requires <ArgumentNullException> (action != null); Contract.Ensures ((Contract.Result <ClockHandler> () != null && (tick > this.CurrentTick)) || Contract.Result <ClockHandler> () == null); return default (ClockHandler); }
public ClockHandler RegisterConditionalAction (Func <bool> condition, ClockAction action) { var new_id = new ClockHandler (); this.all_handlers.Add (new_id, action); this.cond_handlers.Add (condition, new_id); return new_id; }
public ClockHandler RegisterAction (ulong tick, ClockAction action) { if (this.CurrentTick >= tick) return null; var new_id = new ClockHandler (); this.all_handlers.Add (new_id, action); if (! this.tick_handlers.ContainsKey (tick)) this.tick_handlers.Add (tick, new List <ClockHandler> ()); this.tick_handlers [tick].Add (new_id); return new_id; }
// todo: ensure category is sent when adding data public static async Task AddData(ClockAction action, string category) { using (var _command = new SqliteCommand()) { _command.Connection = _connection; // Use parameterized query to prevent SQL injection attacks _command.CommandText = $"insert into {Table} ('Action', 'TimeOfAction', 'Category') values (@action, @time, @category)"; _command.Parameters.AddWithValue("@action", action); _command.Parameters.AddWithValue("@time", DateTimeSQLite(DateTime.Now)); _command.Parameters.AddWithValue("@category", category); await _command.ExecuteReaderAsync(); } }
/// <summary> /// Выполняет регистрацию действия, которое произойдёт в заданный тик. /// </summary> /// <param name = "tick">Номер тика, в который будет выполнено действие.</param> /// <param name = "action">Действие, которое должно произойти.</param> /// <returns>Описатель зарегистрированного действия или <c>null</c>, если действие зарегистрировано неуспешно.</returns> /// <remarks> /// Регистрация действия считается успешной, если оно регистрируется не на текущий тик. /// </remarks> /// <exception cref = "ArgumentNullException"><paramref name = "action" /> является <c>null</c>.</exception> public virtual ClockHandler RegisterAction (ulong tick, ClockAction action) { lock (this.syncRoot) { if (this.CurrentTick < tick) { var id = this.id_gen.GetNext (); this.all_handlers.Add (id, action); if (!this.tick_handlers.ContainsKey (tick)) this.tick_handlers.Add (tick, new List <ulong> ()); this.tick_handlers [tick].Add (id); return new ClockHandler (id); } return null; } }
public ClockHandler RegisterActionAtTime (ulong delta_time, ClockAction action) { return this.RegisterAction (this.CurrentTick + this.CalculateTime (delta_time), action); }
public ClockHandler RegisterAction (ClockAction action) { return this.RegisterAction (this.CurrentTick + 1, action); }
/// <inheritdoc /> public ClockHandler RegisterConditionalAction (Func <bool> condition, ClockAction action) { lock (this.syncRoot) { var id = this.id_gen.GetNext (); this.all_handlers.Add (id, action); this.cond_handlers.Add (condition, id); return new ClockHandler (id); } }
/// <inheritdoc /> public virtual ClockHandler RegisterActionAtTime (ulong delta_time, ClockAction action) { return this.RegisterAction ( this.CurrentTick + (this.TickLength == 0 ? 0 : CeilDiv (delta_time, this.TickLength)), action); }