[API] Implemented System.Transactions (tx preparation) timeout handling
[mono.git] / mcs / class / System.Transactions / System.Transactions / TransactionManager.cs
1 //
2 // TransactionManager.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 #if NET_2_0\r
12 using System.Configuration;\r
13 using System.Transactions.Configuration;
14
15 namespace System.Transactions
16 {
17         public static class TransactionManager
18         {
19                 static TransactionManager()
20                 {\r
21                         defaultSettings = ConfigurationManager.GetSection("system.transactions/defaultSettings") as DefaultSettingsSection;\r
22                         machineSettings = ConfigurationManager.GetSection("system.transactions/machineSettings") as MachineSettingsSection;
23                 }\r
24 \r
25                 static DefaultSettingsSection defaultSettings;\r
26                 static MachineSettingsSection machineSettings;\r
27                 static TimeSpan defaultTimeout = new TimeSpan(0, 1, 0); /* 60 secs */\r
28                 static TimeSpan maxTimeout = new TimeSpan(0, 10, 0); /* 10 mins */
29
30                 public static TimeSpan DefaultTimeout {\r
31                         get {\r
32                                 // Obtain timeout from configuration setting..\r
33                                 //              - http://msdn.microsoft.com/en-us/library/ms973865.aspx\r
34                                 //              - http://sankarsan.wordpress.com/2009/02/01/transaction-timeout-in-systemtransactions/\r
35                                 //      1. sys.txs/defaultSettings[@timeout]\r
36                                 //      2. defaultTimeout\r
37 \r
38                                 if (defaultSettings != null)\r
39                                         return defaultSettings.Timeout;
40
41                                 return defaultTimeout; 
42                         }
43                 }
44
45                 [MonoTODO ("Not implemented")]
46                 public static HostCurrentTransactionCallback HostCurrentCallback {
47                         get { throw new NotImplementedException (); }
48                         set { throw new NotImplementedException (); }
49                 }
50
51                 public static TimeSpan MaximumTimeout {
52                         get {\r
53 \r
54                                 if (machineSettings != null)\r
55                                         return machineSettings.MaxTimeout;
56
57                                 return maxTimeout; 
58                         }
59                 }
60
61                 [MonoTODO ("Not implemented")]
62                 public static void RecoveryComplete (Guid manager)
63                 {
64                         throw new NotImplementedException ();
65                 }
66
67                 [MonoTODO ("Not implemented")]
68                 public static Enlistment Reenlist (Guid manager,
69                         byte[] recoveryInfo,
70                         IEnlistmentNotification notification)
71                 {
72                         throw new NotImplementedException ();
73                 }
74
75                 public static event TransactionStartedEventHandler
76                         DistributedTransactionStarted;
77         }
78 }
79
80 #endif