19 using System.Collections.Generic;
28 private readonly List<ITableEvent>
events;
31 if (tableSource == null)
32 throw new ArgumentNullException(
"tableSource");
37 events =
new List<ITableEvent>();
46 public long CommitId {
get;
internal set; }
48 public IEnumerable<int> AddedRows {
51 var list =
new List<int>();
54 var eventType = tableEvent.EventType;
57 list.Add(tableEvent.RowNumber);
60 var index = list.IndexOf(tableEvent.RowNumber);
66 return list.ToArray();
71 public IEnumerable<int> RemovedRows {
74 var list =
new List<int>();
79 list.Add(tableEvent.RowNumber);
82 return list.ToArray();
87 public int EventCount {
97 if (count > events.Count)
98 throw new Exception(
"Trying to rollback more events than are in the registry.");
100 List<int> toAdd =
new List<int>();
106 toAdd.Add(tableEvent.RowNumber);
109 events.RemoveRange(0, count);
112 for (
int i = 0; i < toAdd.Count; ++i) {
122 events.Add(tableEvent);
131 var rowNum = rowEvent.RowNumber;
133 if (otherRowEvent.RowNumber == rowNum &&
136 String.Format(
"Concurrent Serializable Transaction Conflict(1): " +
137 "Current row remove clash ( row: {0}, table: {1})", rowNum, tableInfo.
TableName));
147 return events.GetEnumerator();
151 IEnumerator IEnumerable.GetEnumerator() {
152 return GetEnumerator();
157 if (index < 0 || index >= events.Count)
158 throw new ArgumentOutOfRangeException(
"index");
160 return events[index];
IEnumerator< ITableEvent > GetEnumerator()
ObjectName TableName
Gets the fully qualified name of the table that is ensured to be unique within the system...
void TestCommitClash(TableInfo tableInfo, TableEventRegistry journal)
Defines a transaction event whose object is a database table identified.
ITableEvent GetEvent(int index)
void Register(ITableEvent tableEvent)
Defines the metadata properties of a table existing within a database.
TableRowEventType
The kind of events that can happen on a table row during the life-time of a transaction.
readonly List< ITableEvent > events
TableEventRegistry(TableSource tableSource)