18 using System.Collections.Generic;
24 namespace Deveel.Data.Transactions {
26 private List<ITransactionEvent>
events;
34 events =
new List<ITransactionEvent>();
43 public IEnumerable<ObjectName> ObjectsCreated {
46 return objectsCreated == null ?
new ObjectName[0] : objectsCreated.ToArray();
51 public IEnumerable<ObjectName> ObjectsDropped {
54 return objectsDropped == null ?
new ObjectName[0] : objectsDropped.ToArray();
59 public IEnumerable<int> TouchedTables {
62 return touchedTables == null ?
new int[0] : touchedTables.ToArray();
67 public IEnumerable<int> TablesCreated {
89 public IEnumerable<int> TablesDropped {
97 public IEnumerable<int> TablesConstraintAltered {
106 bool created =
false;
108 if (objectsCreated != null)
109 created = objectsCreated.Remove(objName);
114 if (objectsDropped == null)
115 objectsDropped =
new List<ObjectName>();
117 objectsDropped.Add(objName);
123 bool dropped =
false;
124 if (objectsDropped != null)
125 dropped = objectsDropped.Remove(objName);
130 if (objectsCreated == null)
131 objectsCreated =
new List<ObjectName>();
133 objectsCreated.Add(objName);
140 throw new ArgumentNullException(
"e");
146 var createdEvent = (ObjectCreatedEvent) e;
147 RegisterObjectCreated(createdEvent.ObjectName);
149 var droppedEvent = (ObjectDroppedEvent) e;
150 RegisterObjectDropped(droppedEvent.ObjectName);
154 var tableEvent = (ITableEvent) e;
155 TouchTable(tableEvent.TableId);
164 if (touchedTables == null)
165 touchedTables =
new List<int>();
167 var index = touchedTables.LastIndexOf(tableId);
168 if (index > 0 && touchedTables[index] == tableId)
172 touchedTables.Add(tableId);
174 touchedTables.Insert(index, tableId);
181 return events.ToArray();
187 GC.SuppressFinalize(
this);
192 if (objectsCreated != null)
193 objectsCreated.Clear();
195 if (objectsDropped != null)
196 objectsDropped.Clear();
201 objectsDropped = null;
202 objectsCreated = null;
List< ITransactionEvent > events
The system implementation of a transaction model that handles isolated operations within a database c...
List< ObjectName > objectsCreated
An event fired when a database object of the given type is created during the lifetime of a transacti...
void RegisterEvent(ITransactionEvent e)
Describes the name of an object within a database.
void RegisterObjectCreated(ObjectName objName)
void Dispose(bool disposing)
A new table was created during a transaction.
An event that happens within a ITransaction life-cycle.
List< ObjectName > objectsDropped
List< int > touchedTables
Defines a transaction event whose object is a database table identified.
The simplest implementation of a transaction.
A transaction event that caused the alteration of a constraints in the table given.
IEnumerable< ITransactionEvent > GetEvents()
void RegisterObjectDropped(ObjectName objName)
TransactionRegistry(ITransaction transaction)
void TouchTable(int tableId)