Fixed conding style and added license/copyright header to new files
[mono.git] / mcs / class / System.Transactions / System.Transactions / TransactionManager.cs
old mode 100755 (executable)
new mode 100644 (file)
index 5405699..a7a62b6
@@ -3,44 +3,68 @@
 //
 // Author:
 //     Atsushi Enomoto  <atsushi@ximian.com>
+//     Ankit Jain       <JAnkit@novell.com>
 //
 // (C)2005 Novell Inc,
+// (C)2006 Novell Inc,
 //
-using System.Collections;
-using System.Collections.Specialized;
-
-#if NET_2_0
+#if NET_2_0\r
+using System.Configuration;\r
+using System.Transactions.Configuration;
 
 namespace System.Transactions
 {
        public static class TransactionManager
        {
-               // it could contain both Transaction and non-tx (Suppress).
-               static Stack tx_states = new Stack ();
+               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 */
 
-               [MonoTODO]
-               public static TimeSpan DefaultTimeout {
-                       get { throw new NotImplementedException (); }
+               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 (); }
                }
 
-               [MonoTODO]
                public static TimeSpan MaximumTimeout {
-                       get { throw new NotImplementedException (); }
+                       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)
@@ -50,28 +74,6 @@ namespace System.Transactions
 
                public static event TransactionStartedEventHandler
                        DistributedTransactionStarted;
-
-               // internals
-               internal static Transaction Current {
-                       get {
-                               if (tx_states.Count == 0)
-                                       return null;
-                               return tx_states.Peek () as Transaction;
-                       }
-                       set {
-                               throw new NotImplementedException ();
-                       }
-               }
-
-               internal static void BeginScope (TransactionScope scope)
-               {
-                       throw new NotImplementedException ();
-               }
-
-               internal static void EndScope (TransactionScope scope)
-               {
-                       throw new NotImplementedException ();
-               }
        }
 }