Merge pull request #1506 from akoeplinger/fix-paste-test
[mono.git] / mcs / class / System.Transactions / System.Transactions / PreparingEnlistment.cs
1 //
2 // PreparingEnlistment.cs
3 //
4 // Author:
5 //      Atsushi Enomoto  <atsushi@ximian.com>
6 //      Ankit Jain       <JAnkit@novell.com>
7 //
8 // (C)2005 Novell Inc,
9 // (C)2006 Novell Inc,
10 //
11
12
13 using System.Threading;
14
15 namespace System.Transactions
16 {
17         public class PreparingEnlistment : Enlistment
18         {
19                 bool prepared = false;
20                 Transaction tx;
21                 IEnlistmentNotification enlisted;
22                 WaitHandle waitHandle;
23                 Exception ex;
24
25                 internal PreparingEnlistment (Transaction tx, IEnlistmentNotification enlisted)
26                 {
27                         this.tx = tx;
28                         this.enlisted = enlisted;
29                         waitHandle = new ManualResetEvent (false);
30                 }
31
32                 public void ForceRollback ()
33                 {
34                         ForceRollback (null);
35                 }
36
37                 internal override void InternalOnDone ()
38                 {
39                         this.Prepared();                        
40                 }
41
42                 [MonoTODO]
43                 public void ForceRollback (Exception ex)
44                 {
45                         tx.Rollback (ex, enlisted);
46                         /* See test RMFail2 */
47                         ((ManualResetEvent) waitHandle).Set ();
48                 }
49
50                 [MonoTODO]
51                 public void Prepared ()
52                 {
53                         prepared = true;
54                         /* See test RMFail2 */
55                         ((ManualResetEvent) waitHandle).Set ();
56                 }
57
58                 [MonoTODO]
59                 public byte [] RecoveryInformation ()
60                 {
61                         throw new NotImplementedException ();
62                 }
63
64                 internal bool IsPrepared {
65                         get { return prepared; }
66                 }
67
68                 internal WaitHandle WaitHandle {
69                         get { return waitHandle; }
70                 }
71
72                 internal IEnlistmentNotification EnlistmentNotification
73                 {
74                         get { return enlisted; }
75                 }
76
77                 // Uncatched exceptions thrown during prepare will
78                 // be saved here so they can be retrieved by TM.
79                 internal Exception Exception
80                 {
81                         get { return ex; }
82                         set { ex = value; }
83                 }
84         }
85 }
86