Merge pull request #819 from brendanzagaeski/patch-1
[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 #if NET_2_0
13
14 using System.Threading;
15
16 namespace System.Transactions
17 {
18         public class PreparingEnlistment : Enlistment
19         {
20                 bool prepared = false;
21                 Transaction tx;
22                 IEnlistmentNotification enlisted;
23                 WaitHandle waitHandle;
24                 Exception ex;
25
26                 internal PreparingEnlistment (Transaction tx, IEnlistmentNotification enlisted)
27                 {
28                         this.tx = tx;
29                         this.enlisted = enlisted;
30                         waitHandle = new ManualResetEvent (false);
31                 }
32
33                 public void ForceRollback ()
34                 {
35                         ForceRollback (null);
36                 }
37
38                 internal override void InternalOnDone ()
39                 {
40                         this.Prepared();                        
41                 }
42
43                 [MonoTODO]
44                 public void ForceRollback (Exception ex)
45                 {
46                         tx.Rollback (ex, enlisted);
47                         /* See test RMFail2 */
48                         ((ManualResetEvent) waitHandle).Set ();
49                 }
50
51                 [MonoTODO]
52                 public void Prepared ()
53                 {
54                         prepared = true;
55                         /* See test RMFail2 */
56                         ((ManualResetEvent) waitHandle).Set ();
57                 }
58
59                 [MonoTODO]
60                 public byte [] RecoveryInformation ()
61                 {
62                         throw new NotImplementedException ();
63                 }
64
65                 internal bool IsPrepared {
66                         get { return prepared; }
67                 }
68
69                 internal WaitHandle WaitHandle {
70                         get { return waitHandle; }
71                 }
72
73                 internal IEnlistmentNotification EnlistmentNotification
74                 {
75                         get { return enlisted; }
76                 }
77
78                 // Uncatched exceptions thrown during prepare will
79                 // be saved here so they can be retrieved by TM.
80                 internal Exception Exception
81                 {
82                         get { return ex; }
83                         set { ex = value; }
84                 }
85         }
86 }
87
88 #endif