DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Transactions.TransactionRegistry Class Reference
Inheritance diagram for Deveel.Data.Transactions.TransactionRegistry:

Public Member Functions

 TransactionRegistry (ITransaction transaction)
 
void RegisterEvent (ITransactionEvent e)
 
IEnumerable< ITransactionEventGetEvents ()
 
void Dispose ()
 

Properties

ITransaction Transaction [get, private set]
 
IEnumerable< ObjectNameObjectsCreated [get]
 
IEnumerable< ObjectNameObjectsDropped [get]
 
IEnumerable< int > TouchedTables [get]
 
IEnumerable< int > TablesCreated [get]
 
IEnumerable< int > TablesDropped [get]
 
IEnumerable< int > TablesConstraintAltered [get]
 

Private Member Functions

 ~TransactionRegistry ()
 
void RegisterObjectDropped (ObjectName objName)
 
void RegisterObjectCreated (ObjectName objName)
 
void TouchTable (int tableId)
 
void Dispose (bool disposing)
 

Private Attributes

List< ITransactionEventevents
 
List< ObjectNameobjectsCreated
 
List< ObjectNameobjectsDropped
 
List< int > touchedTables
 

Detailed Description

Definition at line 25 of file TransactionRegistry.cs.

Constructor & Destructor Documentation

Deveel.Data.Transactions.TransactionRegistry.TransactionRegistry ( ITransaction  transaction)
inline

Definition at line 31 of file TransactionRegistry.cs.

31  {
32  Transaction = transaction;
33 
34  events = new List<ITransactionEvent>();
35  }
Deveel.Data.Transactions.TransactionRegistry.~TransactionRegistry ( )
inlineprivate

Definition at line 37 of file TransactionRegistry.cs.

Member Function Documentation

void Deveel.Data.Transactions.TransactionRegistry.Dispose ( )
inline

Definition at line 185 of file TransactionRegistry.cs.

185  {
186  Dispose(true);
187  GC.SuppressFinalize(this);
188  }
void Deveel.Data.Transactions.TransactionRegistry.Dispose ( bool  disposing)
inlineprivate

Definition at line 190 of file TransactionRegistry.cs.

190  {
191  if (disposing) {
192  if (objectsCreated != null)
193  objectsCreated.Clear();
194 
195  if (objectsDropped != null)
196  objectsDropped.Clear();
197 
198  events.Clear();
199  }
200 
201  objectsDropped = null;
202  objectsCreated = null;
203  events = null;
204  }
IEnumerable<ITransactionEvent> Deveel.Data.Transactions.TransactionRegistry.GetEvents ( )
inline

Definition at line 179 of file TransactionRegistry.cs.

179  {
180  lock (this) {
181  return events.ToArray();
182  }
183  }
void Deveel.Data.Transactions.TransactionRegistry.RegisterEvent ( ITransactionEvent  e)
inline

Definition at line 137 of file TransactionRegistry.cs.

137  {
138  lock (this) {
139  if (e == null)
140  throw new ArgumentNullException("e");
141 
142  //if (Transaction.ReadOnly())
143  // throw new InvalidOperationException("Transaction is read-only.");
144 
145  if (e is ObjectCreatedEvent) {
146  var createdEvent = (ObjectCreatedEvent) e;
147  RegisterObjectCreated(createdEvent.ObjectName);
148  } else if (e is ObjectDroppedEvent) {
149  var droppedEvent = (ObjectDroppedEvent) e;
150  RegisterObjectDropped(droppedEvent.ObjectName);
151  }
152 
153  if (e is ITableEvent) {
154  var tableEvent = (ITableEvent) e;
155  TouchTable(tableEvent.TableId);
156  }
157 
158  events.Add(e);
159  }
160  }
void Deveel.Data.Transactions.TransactionRegistry.RegisterObjectCreated ( ObjectName  objName)
inlineprivate

Definition at line 121 of file TransactionRegistry.cs.

121  {
122  // If this table name was dropped, then remove from the drop list
123  bool dropped = false;
124  if (objectsDropped != null)
125  dropped = objectsDropped.Remove(objName);
126 
127  // If the above operation didn't remove a table name then add to the
128  // created database objects list.
129  if (!dropped) {
130  if (objectsCreated == null)
131  objectsCreated = new List<ObjectName>();
132 
133  objectsCreated.Add(objName);
134  }
135  }
void Deveel.Data.Transactions.TransactionRegistry.RegisterObjectDropped ( ObjectName  objName)
inlineprivate

Definition at line 105 of file TransactionRegistry.cs.

105  {
106  bool created = false;
107 
108  if (objectsCreated != null)
109  created = objectsCreated.Remove(objName);
110 
111  // If the above operation didn't remove a table name then add to the
112  // dropped database objects list.
113  if (!created) {
114  if (objectsDropped == null)
115  objectsDropped = new List<ObjectName>();
116 
117  objectsDropped.Add(objName);
118  }
119  }
void Deveel.Data.Transactions.TransactionRegistry.TouchTable ( int  tableId)
inlineprivate

Definition at line 162 of file TransactionRegistry.cs.

162  {
163  lock (this) {
164  if (touchedTables == null)
165  touchedTables = new List<int>();
166 
167  var index = touchedTables.LastIndexOf(tableId);
168  if (index > 0 && touchedTables[index] == tableId)
169  return;
170 
171  if (index < 0) {
172  touchedTables.Add(tableId);
173  } else {
174  touchedTables.Insert(index, tableId);
175  }
176  }
177  }

Member Data Documentation

List<ITransactionEvent> Deveel.Data.Transactions.TransactionRegistry.events
private

Definition at line 26 of file TransactionRegistry.cs.

List<ObjectName> Deveel.Data.Transactions.TransactionRegistry.objectsCreated
private

Definition at line 27 of file TransactionRegistry.cs.

List<ObjectName> Deveel.Data.Transactions.TransactionRegistry.objectsDropped
private

Definition at line 28 of file TransactionRegistry.cs.

List<int> Deveel.Data.Transactions.TransactionRegistry.touchedTables
private

Definition at line 29 of file TransactionRegistry.cs.

Property Documentation

IEnumerable<ObjectName> Deveel.Data.Transactions.TransactionRegistry.ObjectsCreated
get

Definition at line 43 of file TransactionRegistry.cs.

IEnumerable<ObjectName> Deveel.Data.Transactions.TransactionRegistry.ObjectsDropped
get

Definition at line 51 of file TransactionRegistry.cs.

IEnumerable<int> Deveel.Data.Transactions.TransactionRegistry.TablesConstraintAltered
get

Definition at line 97 of file TransactionRegistry.cs.

IEnumerable<int> Deveel.Data.Transactions.TransactionRegistry.TablesCreated
get

Definition at line 67 of file TransactionRegistry.cs.

IEnumerable<int> Deveel.Data.Transactions.TransactionRegistry.TablesDropped
get

Definition at line 89 of file TransactionRegistry.cs.

IEnumerable<int> Deveel.Data.Transactions.TransactionRegistry.TouchedTables
get

Definition at line 59 of file TransactionRegistry.cs.

ITransaction Deveel.Data.Transactions.TransactionRegistry.Transaction
getprivate set

Definition at line 41 of file TransactionRegistry.cs.


The documentation for this class was generated from the following file: