Fixed conding style and added license/copyright header to new files
[mono.git] / mcs / class / System.Transactions / System.Transactions / TransactionManager.cs
index 130df9be27a65f9f6936c60c315b1ebe40675d35..a7a62b6388e559e3045f7dc5effcfaa16d94243f 100644 (file)
@@ -8,38 +8,63 @@
 // (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]
+               [MonoTODO ("Not implemented")]
                public static HostCurrentTransactionCallback HostCurrentCallback {
                        get { throw new NotImplementedException (); }
                        set { throw new NotImplementedException (); }
                }
 
                public static TimeSpan MaximumTimeout {
-                       get { return maxTimeout; }
+                       get {\r
+\r
+                               if (machineSettings != null)\r
+                                       return machineSettings.MaxTimeout;
+
+                               return maxTimeout; 
+                       }
                }
 
-               [MonoTODO]
+               [MonoTODO ("Not implemented")]
                public static void RecoveryComplete (Guid manager)
                {
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
+               [MonoTODO ("Not implemented")]
                public static Enlistment Reenlist (Guid manager,
                        byte[] recoveryInfo,
                        IEnlistmentNotification notification)