public void Commit() { if (!IsStarted) { throw new InvalidOperationException(); } if (IsDismissed) { throw new InvalidOperationException(); } var completionSet = SelectedCompletionSet; var completion = completionSet?.SelectionStatus.Completion; if (completion != null) { Debug.Assert(completionSet.SelectionStatus.IsSelected); if (completion is ICustomCommit customCommit) { customCommit.Commit(); } else { var insertionText = completion.InsertionText; if (insertionText != null) { var replaceSpan = completionSet.ApplicableTo; var buffer = replaceSpan.TextBuffer; var span = replaceSpan.GetSpan(buffer.CurrentSnapshot); buffer.Replace(span.Span, insertionText); } } } Committed?.Invoke(this, EventArgs.Empty); Dismiss(); }
public void CommitTransaction() { var operationId = Guid.Empty; try { operationId = _diagnosticListener.WriteDbSessionCommitBefore(this); #region Impl if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug("CommitTransaction."); } if (Transaction == null) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError("Before CommitTransaction,Please BeginTransaction first!"); } throw new SmartSqlException("Before CommitTransaction,Please BeginTransaction first!"); } Transaction.Commit(); ReleaseTransaction(); Committed?.Invoke(this, DbSessionEventArgs.None); #endregion _diagnosticListener.WriteDbSessionCommitAfter(operationId, this); } catch (Exception ex) { _diagnosticListener.WriteDbSessionCommitError(operationId, this, ex); throw; } }
private void OnCommit() { hotSpot.Text = Text.Trim(); Committed?.Invoke(this, EventArgs.Empty); Visible = false; }
protected virtual void OnCommitted() { if (Committed == null) { return; } Committed.Invoke(this, new EventArgs()); }
/// <summary> /// Asynchronously commits all changes made in this unit of work context to the database. /// </summary> /// <param name="cancellationToken"> /// The token that propagates a cancellation request to interrupt the operation. /// </param> /// <returns> /// A task that represents the asynchronous commit operation. /// The task result contains the number of affected entries in the database. /// </returns> /// <exception cref="DbUpdateException">Thrown when an error is encountered while saving to the database.</exception> /// <exception cref="DbUpdateConcurrencyException">Thrown when a concurrency violation is encountered while saving to the database.</exception> public virtual async Task <int> CommitAsync(CancellationToken cancellationToken = default) { Committing?.Invoke(this, new UnitOfWorkCommittingEventArgs(_registeredRepositories)); var affectedEntries = await Context.SaveChangesAsync(cancellationToken).ConfigureAwait(false); Committed?.Invoke(this, new UnitOfWorkCommittedEventArgs(affectedEntries, _registeredRepositories)); return(affectedEntries); }
/// <summary> /// Commits all changes made in this unit of work context to the database. /// </summary> /// <returns>The number of affected entries in the database.</returns> /// <exception cref="DbUpdateException">Thrown when an error is encountered while saving to the database.</exception> /// <exception cref="DbUpdateConcurrencyException">Thrown when a concurrency violation is encountered while saving to the database.</exception> public virtual int Commit() { Committing?.Invoke(this, new UnitOfWorkCommittingEventArgs(_registeredRepositories)); var affectedEntries = Context.SaveChanges(); Committed?.Invoke(this, new UnitOfWorkCommittedEventArgs(affectedEntries, _registeredRepositories)); return(affectedEntries); }
public void Dispose() { if (_isCommitted) { throw new Exception("UnitOfWork was already disposed earlier."); } Committed?.Invoke(this, EventArgs.Empty); _isCommitted = true; }
public async Task Commit(CompletionItem item = null) { if (item == null) { item = CompletionListControl.Items[CompletionListControl.SelectedIndex].item; } Committed?.Invoke(this, new CompletionCommitEventArgs(item)); await SetSelectedIndex(-1); }
public Notification Crime(IRole role, Enum key) { if (Framing != null) { return(Notification.Chat(role, key, User, Framing.Crime)); } if (Innocent()) { return(Notification.Chat(CrimeKey.NotGuilty, User)); } var randomIndex = User.Match.Random.Next(Committed.Count); var crime = Committed.ElementAt(randomIndex); return(Notification.Chat(role, key, User, crime)); }
public void Commit() { if (!IsStarted) { throw new InvalidOperationException(); } if (IsDismissed) { throw new InvalidOperationException(); } if (SelectedCompletionSet.SelectionStatus.IsSelected) { SelectedCompletionSet.Commit(); } Committed?.Invoke(this, EventArgs.Empty); Dismiss(); }
private void OnCommit() { hotSpot.Text = Text.Trim(); try { hotSpot.Node.Update(hotSpot); } catch (Exception ex) { Program.Logger.Log(ex); } Committed?.Invoke(this, EventArgs.Empty); Visible = false; }
/// <summary> /// Commits the current transaction. /// </summary> public void Commit() { if (!_isInTransaction) { throw new InvalidOperationException("The transaction was either already committed or rolled back."); } _rollbackOnDispose = false; _isInTransaction = false; Committing?.Invoke(this, EventArgs.Empty); _parentTransaction.Release(_savePoint); Committed?.Invoke(this, EventArgs.Empty); Finished?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Commits the current transaction. /// </summary> public void Commit() { if (_isDisposed) { throw new ObjectDisposedException(GetType().FullName); } if (!_isInTransaction) { throw new InvalidOperationException("The transaction was either already committed or rolled back."); } Committing?.Invoke(this, EventArgs.Empty); _connection.Commit(); Committed?.Invoke(this, EventArgs.Empty); FinishTransaction(); }
public TEntity Create <TEntity>(TEntity entity) where TEntity : class { PendingActions.Add(() => { Committed.Add(entity); if (EntityHelper.IsIdentityType(typeof(TEntity))) { int maxKey = GetAll <TEntity>().Max(ent => EntityHelper.GetKeys(ent).OfType <int>().First()); EntityHelper.SetKeys(entity, maxKey + 1); } }); UpdateAssociations(entity); return(entity); }
public void Delete <TEntity>(params TEntity[] entities) where TEntity : class { if (entities == null) { throw new ApplicationException("InMemoryDataAccesor: Passed null to delete"); } foreach (TEntity entity in entities) { TEntity current = entity; if (!Committed.Contains(current)) { throw new ApplicationException("InMemoryDataAccesor: Trying to delete entity that is not in the database"); } PendingActions.Add(() => Committed.Remove(current)); } }
private void UpdateAssociations <TEntity>(TEntity entity) { foreach (PropertyInfo associationProp in EntityHelper.AssociationPropertyMap[typeof(TEntity)]) { IEnumerable values = (IEnumerable)associationProp.GetValue(entity); foreach (object value in values) { Type objType = value.GetType(); object original = Committed.FirstOrDefault(obj => obj.GetType() == value.GetType() && EntityHelper.AreKeysEqual(obj, value)); if (original == null) { CreateMethod.MakeGenericMethod(objType).Invoke(this, new[] { value }); } else { UpdateMethod.MakeGenericMethod(objType).Invoke(this, new[] { value }); } } } }
public void Commit() { if (SelectedCompletionSet != null) { Completion selectedCompletion = SelectedCompletionSet.SelectionStatus.Completion; if (selectedCompletion != null && selectedCompletion.InsertionText != null) { ITrackingSpan applicableTo = SelectedCompletionSet.ApplicableTo; ITextBuffer buffer = applicableTo.TextBuffer; ITextSnapshot snapshot = buffer.CurrentSnapshot; SnapshotSpan replaceSpan = applicableTo.GetSpan(snapshot); buffer.Replace(replaceSpan.Span, selectedCompletion.InsertionText); TextView.Caret.EnsureVisible(); } } Committed?.Invoke(this, EventArgs.Empty); Dismiss(); }
/// <summary> /// Completes the unit of work. /// </summary> /// <remarks> /// By default, if the subject of the unit of work implements <see cref="IDisposable" />, then it will disposed when the root unit of work is disposed. /// </remarks> public void Dispose() { var subject = Subject; if (!canCommit && subject != null) { RejectAll(); } if (isOutermost) { if (!rejected && subject != null) { try { commit(this); // check again that Commit did not fail in a way that requires rejection if (!rejected) { Committed?.Invoke(this, subject); } else { RejectAll(); } } catch (Exception ex) { RejectDueTo(ex); RejectAll(); } } SetInContext(null); disposables.Dispose(); resources.Clear(); } disposed = true; }
public void Add(Key crime) { Committed.Add(crime); }
protected virtual void OnCommitted(SvnCommittedEventArgs e) { Committed?.Invoke(this, e); }
public void Commit() { raw.Commit(); Committed?.Invoke(this, EventArgs.Empty); }
public IQueryable <TEntity> GetAll <TEntity>() where TEntity : class { return(Committed.OfType <TEntity>().AsQueryable()); }
private void OnCommitted(CommitResult commitResult) => Committed?.Invoke(this, new CommitResultEventArgs(commitResult));
private void Commit(string credential) => Committed?.Invoke(credential);