Fixed conding style and added license/copyright header to new files
[mono.git] / mcs / class / System.Transactions / System.Transactions / TransactionManager.cs
index 85d12169e10c09b4af5b16c10b702592cd96132a..a7a62b6388e559e3045f7dc5effcfaa16d94243f 100644 (file)
@@ -8,19 +8,38 @@
 // (C)2005 Novell Inc,
 // (C)2006 Novell Inc,
 //
-#if NET_2_0
+#if NET_2_0\r
+using System.Configuration;\r
+using System.Transactions.Configuration;
 
 namespace System.Transactions
 {
        public static class TransactionManager
        {
-               /* 60 secs */
-               static TimeSpan defaultTimeout = new TimeSpan (0, 1, 0);
-               /* 10 mins */
-               static TimeSpan maxTimeout = new TimeSpan (0, 10, 0);
+               static TransactionManager ()
+               {\r
+                       defaultSettings = ConfigurationManager.GetSection ("system.transactions/defaultSettings") as DefaultSettingsSection;\r
+                       machineSettings = ConfigurationManager.GetSection ("system.transactions/machineSettings") as MachineSettingsSection;
+               }\r
+\r
+               static DefaultSettingsSection defaultSettings;\r
+               static MachineSettingsSection machineSettings;\r
+               static TimeSpan defaultTimeout = new TimeSpan (0, 1, 0); /* 60 secs */\r
+               static TimeSpan maxTimeout = new TimeSpan (0, 10, 0); /* 10 mins */
 
-               public static TimeSpan DefaultTimeout {
-                       get { return defaultTimeout; }
+               public static TimeSpan DefaultTimeout {\r
+                       get {\r
+                               // Obtain timeout from configuration setting..\r
+                               //              - http://msdn.microsoft.com/en-us/library/ms973865.aspx\r
+                               //              - http://sankarsan.wordpress.com/2009/02/01/transaction-timeout-in-systemtransactions/\r
+                               //      1. sys.txs/defaultSettings[@timeout]\r
+                               //      2. defaultTimeout\r
+\r
+                               if (defaultSettings != null)\r
+                                       return defaultSettings.Timeout;
+
+                               return defaultTimeout; 
+                       }
                }
 
                [MonoTODO ("Not implemented")]
@@ -30,7 +49,13 @@ namespace System.Transactions
                }
 
                public static TimeSpan MaximumTimeout {
-                       get { return maxTimeout; }
+                       get {\r
+\r
+                               if (machineSettings != null)\r
+                                       return machineSettings.MaxTimeout;
+
+                               return maxTimeout; 
+                       }
                }
 
                [MonoTODO ("Not implemented")]