private void InvokeUpdating(UpdatingEventArgs <TPar> e) { this.LogDebug("Invoke updating"); var handler = Updating; if (handler != null) { handler(this, e); } }
public virtual TRes Update(TPar param = default(TPar)) { if (!Equals(param, default(TPar))) { this.LogDebugFormat("Update with param: {0}", param); } else { this.LogDebug("Update without param"); } if (!UpdateAllowed) { throw new InvalidOperationException("Update is not allowed"); } lock (_syncRoot) { Buzy = true; var cancelArgs = new UpdatingEventArgs <TPar>(param); try { InvokeUpdating(cancelArgs); if (cancelArgs.Cancel) { throw new UpdatingCancelledException(cancelArgs.CancelReason); } this.LogDebug("Call OnUpdate"); TRes result = OnUpdate(param); InvokeUpdated(new UpdatedEventArgs <TRes>(result)); LastUpdated = DateTime.Now; IsUpdated = true; return(result); } finally { Buzy = false; } } }