2using System.Threading.Tasks;
24 this.transactions =
new Cache<Guid, T>(
int.MaxValue, TransactionTimeout, TransactionTimeout,
true);
25 this.transactions.Removed += this.Transactions_Removed;
58 this.transactions.Removed -= this.Transactions_Removed;
59 this.transactions.Clear();
60 this.transactions.Dispose();
94 return this.transactions.Remove(Id);
104 if (this.transactions.TryGetValue(
Transaction.
Id, out T Transaction2) &&
121 return this.transactions.TryGetValue(Id, out
Transaction);
129 public async Task<bool>
Prepare(Guid TransactionId)
133 if (!this.transactions.TryGetValue(TransactionId, out T
Transaction))
150 public async Task<bool>
Execute(Guid TransactionId)
154 if (!this.transactions.TryGetValue(TransactionId, out T
Transaction))
171 public async Task<bool>
Commit(Guid TransactionId)
175 if (!this.transactions.TryGetValue(TransactionId, out T
Transaction))
181 this.transactions.Remove(TransactionId);
197 public async Task<bool>
Rollback(Guid TransactionId)
201 if (!this.transactions.TryGetValue(TransactionId, out T
Transaction))
207 this.transactions.Remove(TransactionId);
227 for (i = 0; i < c; i++)
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
Implements an in-memory cache.
Event arguments for cache item removal events.
ValueType Value
Value of item that was removed.
RemovedReason Reason
Reason for removing the item.
Static class that dynamically manages types and interfaces available in the runtime environment.
static object Instantiate(Type Type, params object[] Arguments)
Returns an instance of the type Type . If one needs to be created, it is. If the constructor requires...
Abstract base class for transactions.
TransactionState State
Transaction state.
async Task< bool > Commit()
Commits any changes made during the execution phase.
async Task< bool > Prepare()
Prepares the transaction for execution. This step can be used for validation and authorization of the...
async Task Abort()
Aborts the transaction.
async Task< bool > Execute()
Executes the transaction.
async Task< bool > Rollback()
Rolls back any changes made during the execution phase.
Module making sure no unfinished transactions are left when system ends.
static void Register(ITransactions Transactions)
Registers a collection of transactions with the module.
static bool Unregister(ITransactions Transactions)
Unregisters a collection of transactions with the module.
Maintains a collection of active transactions.
bool TryGetTransaction(Guid Id, out T Transaction)
Tries to get a transaction, given its ID.
Transactions(TimeSpan TransactionTimeout)
Maintains a collection of active transactions.
void Register(T Transaction)
Register a transaction created elsewhere with the collection.
bool Unregister(T Transaction)
Unregisters a transaction.
async Task< bool > Execute(Guid TransactionId)
Executes a transaction in the collection.
T2 CreateNew< T2 >(params object[] Arguments)
Creates a new transaction
async Task< bool > Prepare(Guid TransactionId)
Prepares a transaction in the collection.
void Dispose()
Rolls back any pending transactions and disposes of the object.
async Task< bool > Rollback(Guid TransactionId)
Prepares a transaction in the collection.
async Task< bool > Commit(Guid TransactionId)
Cimmits a transaction in the collection.
Task< ITransaction[]> GetTransactions()
Gets pending transactions.
bool Unregister(Guid Id)
Unregisters a transaction.
Interface for transactions
Interface for collections of transactions that can be monitored by TransactionModule.
RemovedReason
Reason for removing the item.
TransactionState
State of a transaction