[corlib] Disable a test that is incompatible with how nunitlite runs tests
[mono.git] / mcs / class / corlib / Microsoft.Win32 / UnixRegistryApi.cs
index 1542d1bfff14b00e413397deb065cefbdc8ec2c8..30a035593a8b4f458c2e3a7adea3d6600ca873ce 100644 (file)
@@ -37,7 +37,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !NET_2_1
+#if !MOBILE
 
 using System;
 using System.Collections;
@@ -446,6 +446,24 @@ namespace Microsoft.Win32 {
                        throw new Exception ("Could not get root for dir " + dir);
                }
 
+               public static void Drop (RegistryKey rkey)
+               {
+                       lock (typeof (KeyHandler)) {
+                               KeyHandler k = (KeyHandler) key_to_handler [rkey];
+                               if (k == null)
+                                       return;
+                               key_to_handler.Remove (rkey);
+
+                               // remove cached KeyHandler if no other keys reference it
+                               int refCount = 0;
+                               foreach (DictionaryEntry de in key_to_handler)
+                                       if (de.Value == k)
+                                               refCount++;
+                               if (refCount == 0)
+                                       dir_to_handler.Remove (k.Dir);
+                       }
+               }
+
                public static void Drop (string dir)
                {
                        lock (typeof (KeyHandler)) {
@@ -878,6 +896,7 @@ namespace Microsoft.Win32 {
                
                public void Close (RegistryKey rkey)
                {
+                       KeyHandler.Drop (rkey);
                }
 
                public object GetValue (RegistryKey rkey, string name, object default_value, RegistryValueOptions options)
@@ -1010,5 +1029,5 @@ namespace Microsoft.Win32 {
        }
 }
 
-#endif // NET_2_1
+#endif // MOBILE