Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Transaction.cs
Go to the documentation of this file.
5
6namespace System.Transactions;
7
9{
11
12 internal bool _complete;
13
14 internal int _cloneId;
15
16 internal int _disposed;
17
19
21
22 public static Transaction? Current
23 {
24 get
25 {
27 if (log.IsEnabled())
28 {
29 log.MethodEnter(TraceSourceType.TraceSourceBase, "Transaction.get_Current");
30 }
32 if (currentScope != null && currentScope.ScopeComplete)
33 {
35 }
36 if (log.IsEnabled())
37 {
38 log.MethodExit(TraceSourceType.TraceSourceBase, "Transaction.get_Current");
39 }
40 return current;
41 }
42 set
43 {
45 if (log.IsEnabled())
46 {
47 log.MethodEnter(TraceSourceType.TraceSourceBase, "Transaction.set_Current");
48 }
49 if (InteropMode(ContextData.TLSCurrentData.CurrentScope) != 0)
50 {
51 if (log.IsEnabled())
52 {
53 log.InvalidOperation("Transaction", "Transaction.set_Current");
54 }
56 }
59 if (log.IsEnabled())
60 {
61 log.MethodExit(TraceSourceType.TraceSourceBase, "Transaction.set_Current");
62 }
63 }
64 }
65
66 internal bool Disposed => _disposed == 1;
67
69 {
70 get
71 {
72 Guid result = Guid.Empty;
73 if (_internalTransaction != null)
74 {
76 }
77 return result;
78 }
79 }
80
82 {
83 get
84 {
86 if (log.IsEnabled())
87 {
88 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "TransactionInformation");
89 }
90 if (Disposed)
91 {
92 throw new ObjectDisposedException("Transaction");
93 }
95 if (transactionInformation == null)
96 {
99 }
100 if (log.IsEnabled())
101 {
102 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "TransactionInformation");
103 }
105 }
106 }
107
109 {
110 get
111 {
113 if (log.IsEnabled())
114 {
115 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "IsolationLevel");
116 }
117 if (Disposed)
118 {
119 throw new ObjectDisposedException("Transaction");
120 }
121 if (log.IsEnabled())
122 {
123 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "IsolationLevel");
124 }
125 return _isoLevel;
126 }
127 }
128
130 {
131 get
132 {
134 if (log.IsEnabled())
135 {
136 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "PromoterType");
137 }
138 if (Disposed)
139 {
140 throw new ObjectDisposedException("Transaction");
141 }
143 {
145 }
146 }
147 }
148
168
169 public event TransactionCompletedEventHandler? TransactionCompleted
170 {
171 add
172 {
173 if (Disposed)
174 {
175 throw new ObjectDisposedException("Transaction");
176 }
178 {
180 }
181 }
182 remove
183 {
185 {
187 }
188 }
189 }
190
195
222
235
250
257
274
275 public override int GetHashCode()
276 {
278 }
279
280 public override bool Equals([NotNullWhen(true)] object? obj)
281 {
283 {
284 return _internalTransaction.TransactionHash == transaction._internalTransaction.TransactionHash;
285 }
286 return false;
287 }
288
289 public static bool operator ==(Transaction? x, Transaction? y)
290 {
291 return x?.Equals(y) ?? ((object)y == null);
292 }
293
294 public static bool operator !=(Transaction? x, Transaction? y)
295 {
296 if ((object)x != null)
297 {
298 return !x.Equals(y);
299 }
300 return (object)y != null;
301 }
302
303 public byte[] GetPromotedToken()
304 {
306 if (log.IsEnabled())
307 {
308 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "GetPromotedToken");
309 }
310 if (Disposed)
311 {
312 throw new ObjectDisposedException("Transaction");
313 }
314 byte[] array;
316 {
318 }
319 byte[] array2 = new byte[array.Length];
320 Array.Copy(array, array2, array2.Length);
321 return array2;
322 }
323
325 {
327 if (log.IsEnabled())
328 {
329 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "EnlistDurable");
330 }
331 if (Disposed)
332 {
333 throw new ObjectDisposedException("Transaction");
334 }
336 {
337 throw new ArgumentException(System.SR.BadResourceManagerId, "resourceManagerIdentifier");
338 }
339 if (enlistmentNotification == null)
340 {
341 throw new ArgumentNullException("enlistmentNotification");
342 }
343 if (enlistmentOptions != 0 && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
344 {
345 throw new ArgumentOutOfRangeException("enlistmentOptions");
346 }
347 if (_complete)
348 {
350 }
352 {
354 if (log.IsEnabled())
355 {
356 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "EnlistDurable");
357 }
358 return result;
359 }
360 }
361
363 {
365 if (log.IsEnabled())
366 {
367 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "EnlistDurable");
368 }
369 if (Disposed)
370 {
371 throw new ObjectDisposedException("Transaction");
372 }
374 {
375 throw new ArgumentException(System.SR.BadResourceManagerId, "resourceManagerIdentifier");
376 }
377 if (singlePhaseNotification == null)
378 {
379 throw new ArgumentNullException("singlePhaseNotification");
380 }
381 if (enlistmentOptions != 0 && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
382 {
383 throw new ArgumentOutOfRangeException("enlistmentOptions");
384 }
385 if (_complete)
386 {
388 }
390 {
392 if (log.IsEnabled())
393 {
394 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "EnlistDurable");
395 }
396 return result;
397 }
398 }
399
400 public void Rollback()
401 {
403 if (log.IsEnabled())
404 {
405 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "Rollback");
406 log.TransactionRollback(this, "Transaction");
407 }
408 if (Disposed)
409 {
410 throw new ObjectDisposedException("Transaction");
411 }
413 {
415 }
416 if (log.IsEnabled())
417 {
418 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "Rollback");
419 }
420 }
421
422 public void Rollback(Exception? e)
423 {
425 if (log.IsEnabled())
426 {
427 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "Rollback");
428 log.TransactionRollback(this, "Transaction");
429 }
430 if (Disposed)
431 {
432 throw new ObjectDisposedException("Transaction");
433 }
435 {
437 }
438 if (log.IsEnabled())
439 {
440 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "Rollback");
441 }
442 }
443
445 {
447 if (log.IsEnabled())
448 {
449 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "EnlistVolatile");
450 }
451 if (Disposed)
452 {
453 throw new ObjectDisposedException("Transaction");
454 }
455 if (enlistmentNotification == null)
456 {
457 throw new ArgumentNullException("enlistmentNotification");
458 }
459 if (enlistmentOptions != 0 && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
460 {
461 throw new ArgumentOutOfRangeException("enlistmentOptions");
462 }
463 if (_complete)
464 {
466 }
468 {
470 if (log.IsEnabled())
471 {
472 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "EnlistVolatile");
473 }
474 return result;
475 }
476 }
477
479 {
481 if (log.IsEnabled())
482 {
483 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "EnlistVolatile");
484 }
485 if (Disposed)
486 {
487 throw new ObjectDisposedException("Transaction");
488 }
489 if (singlePhaseNotification == null)
490 {
491 throw new ArgumentNullException("singlePhaseNotification");
492 }
493 if (enlistmentOptions != 0 && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
494 {
495 throw new ArgumentOutOfRangeException("enlistmentOptions");
496 }
497 if (_complete)
498 {
500 }
502 {
504 if (log.IsEnabled())
505 {
506 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "EnlistVolatile");
507 }
508 return result;
509 }
510 }
511
513 {
515 if (log.IsEnabled())
516 {
517 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "Clone");
518 }
519 if (Disposed)
520 {
521 throw new ObjectDisposedException("Transaction");
522 }
523 if (_complete)
524 {
526 }
527 Transaction result = InternalClone();
528 if (log.IsEnabled())
529 {
530 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "Clone");
531 }
532 return result;
533 }
534
536 {
539 if (log.IsEnabled())
540 {
541 log.TransactionCloneCreate(transaction, "Transaction");
542 }
543 return transaction;
544 }
545
547 {
549 if (log.IsEnabled())
550 {
551 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "DependentClone");
552 }
553 if (cloneOption != 0 && cloneOption != DependentCloneOption.RollbackIfNotComplete)
554 {
555 throw new ArgumentOutOfRangeException("cloneOption");
556 }
557 if (Disposed)
558 {
559 throw new ObjectDisposedException("Transaction");
560 }
561 if (_complete)
562 {
564 }
566 if (log.IsEnabled())
567 {
568 log.TransactionCloneCreate(dependentTransaction, "DependentTransaction");
569 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "DependentClone");
570 }
572 }
573
574 public void Dispose()
575 {
577 }
578
579 internal virtual void InternalDispose()
580 {
582 if (log.IsEnabled())
583 {
584 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "InternalDispose");
585 }
586 if (Interlocked.Exchange(ref _disposed, 1) != 1)
587 {
589 if (num == 0L)
590 {
592 }
593 if (log.IsEnabled())
594 {
595 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "InternalDispose");
596 }
597 }
598 }
599
604
609
611 {
613 if (log.IsEnabled())
614 {
615 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "EnlistPromotableSinglePhase");
616 }
617 if (Disposed)
618 {
619 throw new ObjectDisposedException("Transaction");
620 }
622 {
623 throw new ArgumentNullException("promotableSinglePhaseNotification");
624 }
625 if (promoterType == Guid.Empty)
626 {
627 throw new ArgumentException(System.SR.PromoterTypeInvalid, "promoterType");
628 }
629 if (_complete)
630 {
632 }
633 bool result = false;
635 {
637 }
638 if (log.IsEnabled())
639 {
640 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "EnlistPromotableSinglePhase");
641 }
642 return result;
643 }
644
646 {
648 if (log.IsEnabled())
649 {
650 log.MethodEnter(TraceSourceType.TraceSourceDistributed, this, "PromoteAndEnlistDurable");
651 }
652 if (Disposed)
653 {
654 throw new ObjectDisposedException("Transaction");
655 }
657 {
658 throw new ArgumentException(System.SR.BadResourceManagerId, "resourceManagerIdentifier");
659 }
660 if (promotableNotification == null)
661 {
662 throw new ArgumentNullException("promotableNotification");
663 }
664 if (enlistmentNotification == null)
665 {
666 throw new ArgumentNullException("enlistmentNotification");
667 }
668 if (enlistmentOptions != 0 && enlistmentOptions != EnlistmentOptions.EnlistDuringPrepareRequired)
669 {
670 throw new ArgumentOutOfRangeException("enlistmentOptions");
671 }
672 if (_complete)
673 {
675 }
677 {
679 if (log.IsEnabled())
680 {
681 log.MethodExit(TraceSourceType.TraceSourceDistributed, this, "PromoteAndEnlistDurable");
682 }
683 return result;
684 }
685 }
686
688 {
690 if (log.IsEnabled())
691 {
692 log.MethodEnter(TraceSourceType.TraceSourceLtm, this, "SetDistributedTransactionIdentifier");
693 }
694 if (Disposed)
695 {
696 throw new ObjectDisposedException("Transaction");
697 }
698 if (promotableNotification == null)
699 {
700 throw new ArgumentNullException("promotableNotification");
701 }
703 {
704 throw new ArgumentException(null, "distributedTransactionIdentifier");
705 }
706 if (_complete)
707 {
709 }
711 {
713 if (log.IsEnabled())
714 {
715 log.MethodExit(TraceSourceType.TraceSourceLtm, this, "SetDistributedTransactionIdentifier");
716 }
717 }
718 }
719
729}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
static ? Delegate Remove(Delegate? source, Delegate? value)
Definition Delegate.cs:463
static string BadResourceManagerId
Definition SR.cs:18
static string TransactionScopeComplete
Definition SR.cs:60
static string PromoterTypeInvalid
Definition SR.cs:82
static string CannotSetCurrent
Definition SR.cs:22
Definition SR.cs:7
static int Exchange(ref int location1, int value)
static int Decrement(ref int location)
static int Increment(ref int location)
static void ClearCurrentData(ContextKey contextKey, bool removeContextData)
static ContextData LookupContextData(TxLookup defaultLookup)
static ContextData TLSCurrentData
static Transaction GetContextTransaction(ContextData contextData)
TransactionCompletedEventHandler _transactionCompletedDelegate
TransactionTraceIdentifier TransactionTraceId
static Exception CreateTransactionCompletedException(Guid distributedTxId)
static HostCurrentTransactionCallback s_currentDelegate
static void ValidateIsolationLevel(IsolationLevel transactionIsolationLevel)
virtual byte[] PromotedToken(InternalTransaction tx)
virtual Enlistment EnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
virtual void Rollback(InternalTransaction tx, Exception e)
virtual Enlistment PromoteAndEnlistDurable(InternalTransaction tx, Guid resourceManagerIdentifier, IPromotableSinglePhaseNotification promotableNotification, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
virtual Enlistment EnlistVolatile(InternalTransaction tx, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction)
virtual void AddOutcomeRegistrant(InternalTransaction tx, TransactionCompletedEventHandler transactionCompletedDelegate)
virtual bool EnlistPromotableSinglePhase(InternalTransaction tx, IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Transaction atomicTransaction, Guid promoterType)
virtual void Promote(InternalTransaction tx)
virtual void SetDistributedTransactionId(InternalTransaction tx, IPromotableSinglePhaseNotification promotableNotification, Guid distributedTransactionIdentifier)
Enlistment EnlistDurable(Guid resourceManagerIdentifier, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)
static void GetCurrentTransactionAndScope(TxLookup defaultLookup, out Transaction current, out TransactionScope currentScope, out Transaction contextTransaction)
TransactionCompletedEventHandler? TransactionCompleted
TransactionTraceIdentifier TransactionTraceId
bool EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification)
InternalTransaction _internalTransaction
static Transaction FastGetTransaction(TransactionScope currentScope, ContextData contextData, out Transaction contextTransaction)
Transaction(IsolationLevel isoLevel, InternalTransaction internalTransaction)
Enlistment EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)
DistributedTransaction Promote()
Enlistment PromoteAndEnlistDurable(Guid resourceManagerIdentifier, IPromotableSinglePhaseNotification promotableNotification, ISinglePhaseNotification enlistmentNotification, EnlistmentOptions enlistmentOptions)
Transaction(IsolationLevel isoLevel, ISimpleTransactionSuperior superior)
Enlistment EnlistDurable(Guid resourceManagerIdentifier, ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
bool EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification promotableSinglePhaseNotification, Guid promoterType)
TransactionTraceIdentifier _traceIdentifier
TransactionInformation TransactionInformation
void SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification promotableNotification, Guid distributedTransactionIdentifier)
static bool operator==(Transaction? x, Transaction? y)
static bool operator!=(Transaction? x, Transaction? y)
Transaction(DistributedTransaction distributedTransaction)
static EnterpriseServicesInteropOption InteropMode(TransactionScope currentScope)
static ? Transaction Current
Enlistment EnlistVolatile(ISinglePhaseNotification singlePhaseNotification, EnlistmentOptions enlistmentOptions)
DependentTransaction DependentClone(DependentCloneOption cloneOption)
override bool Equals([NotNullWhen(true)] object? obj)
static readonly TransactionsEtwProvider Log
void GetObjectData(SerializationInfo info, StreamingContext context)
delegate void TransactionCompletedEventHandler(object? sender, TransactionEventArgs e)
static readonly Guid Empty
Definition Guid.cs:86