Commit 49c8e94

mo_khan <mo@mokhan.ca>
2009-05-10 17:18:25
implemented the singleton scoped storage
1 parent 0e3b998
Changed files (4)
product/Gorilla.Commons.Infrastructure/Transactions/Context.cs
@@ -6,10 +6,6 @@ namespace Gorilla.Commons.Infrastructure.Transactions
     {
         readonly IDictionary items;
 
-        //public Context() : this(new Hashtable())
-        //{
-        //}
-
         public Context(IDictionary items)
         {
             this.items = items;
product/Gorilla.Commons.Infrastructure/Transactions/PerThread.cs
@@ -37,17 +37,17 @@ namespace Gorilla.Commons.Infrastructure.Transactions
 
         IDictionary get_items()
         {
-            var id = System.Threading.Thread.CurrentThread.ManagedThreadId;
+            var id = Thread.CurrentThread.ManagedThreadId;
             within_lock(() =>
                             {
                                 if (!slots.ContainsKey(id))
                                 {
-                                    var slot = System.Threading.Thread.GetNamedDataSlot(GetType().FullName);
+                                    var slot = Thread.GetNamedDataSlot(GetType().FullName);
                                     slots.Add(id, slot);
-                                    System.Threading.Thread.SetData(slot, new Hashtable());
+                                    Thread.SetData(slot, new Hashtable());
                                 }
                             });
-            return (IDictionary) System.Threading.Thread.GetData(slots[id]);
+            return (IDictionary) Thread.GetData(slots[id]);
         }
 
         void within_lock(Action action)
product/Gorilla.Commons.Infrastructure/Transactions/SingletonScopedStorage.cs
@@ -0,0 +1,14 @@
+using System.Collections;
+
+namespace Gorilla.Commons.Infrastructure.Transactions
+{
+    public class SingletonScopedStorage : IScopedStorage
+    {
+        static public readonly IDictionary storage = new Hashtable();
+
+        public IDictionary provide_storage()
+        {
+            return storage;
+        }
+    }
+}
\ No newline at end of file
product/Gorilla.Commons.Infrastructure/Gorilla.Commons.Infrastructure.csproj
@@ -156,6 +156,7 @@
     <Compile Include="Transactions\SessionNotStartedException.cs" />
     <Compile Include="Transactions\SessionProvider.cs" />
     <Compile Include="Transactions\SessionSpecs.cs" />
+    <Compile Include="Transactions\SingletonScopedStorage.cs" />
     <Compile Include="Transactions\StatementRegistry.cs" />
     <Compile Include="Transactions\TrackerEntry.cs" />
     <Compile Include="Transactions\TrackerEntryMapper.cs" />