Moved ProviderCollectionTest.cs from System assembly to System.Configuration.
[mono.git] / mcs / class / System / System.IO / FileSystemWatcher.cs
index 047492ce32ba548738ec5360926e2e286e3982ac..88dd5d813dd7c34cdb0757f5046af06a671c75e8 100644 (file)
@@ -32,6 +32,7 @@
 //
 
 using System.ComponentModel;
+using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Security.Permissions;
@@ -117,7 +118,7 @@ namespace System.IO {
                                int mode = 0;
                                if (managed == null)
                                        mode = InternalSupportsFSW ();
-
+                               
                                bool ok = false;
                                switch (mode) {
                                case 1: // windows
@@ -138,11 +139,23 @@ namespace System.IO {
                                        break;
                                }
 
-                               if (mode == 0 || !ok)
-                                       DefaultWatcher.GetInstance (out watcher);
+                               if (mode == 0 || !ok) {
+                                       if (String.Compare (managed, "disabled", true) == 0)
+                                               NullFileWatcher.GetInstance (out watcher);
+                                       else
+                                               DefaultWatcher.GetInstance (out watcher);
+                               }
+
+                               ShowWatcherInfo ();
                        }
                }
 
+               [Conditional ("DEBUG"), Conditional ("TRACE")]
+               void ShowWatcherInfo ()
+               {
+                       Console.WriteLine ("Watcher implementation: {0}", watcher != null ? watcher.GetType ().ToString () : "<none>");
+               }
+               
                #endregion // Constructors
 
                #region Properties
@@ -332,10 +345,9 @@ namespace System.IO {
 
                #region Methods
        
-               [MonoTODO]
                public void BeginInit ()
                {
-                       throw new NotImplementedException (); 
+                       // Not necessary in Mono
                }
 
                protected override void Dispose (bool disposing)
@@ -354,10 +366,9 @@ namespace System.IO {
                        Stop ();
                }
                
-               [MonoTODO]
                public void EndInit ()
                {
-                       throw new NotImplementedException (); 
+                       // Not necessary in Mono
                }
 
                enum EventType {
@@ -371,19 +382,16 @@ namespace System.IO {
                                return;
 
                        if (synchronizingObject == null) {
-                               Delegate [] delegates = ev.GetInvocationList ();
-                               if (evtype == EventType.RenameEvent) {
-                                       foreach (RenamedEventHandler d in delegates){
-                                               d.BeginInvoke (this, (RenamedEventArgs) arg, null, null);
-                                       }
-                               } else if (evtype == EventType.ErrorEvent) {
-                                       foreach (ErrorEventHandler d in delegates){
-                                               d.BeginInvoke (this, (ErrorEventArgs) arg, null, null);
-                                       }
-                               } else {
-                                       foreach (FileSystemEventHandler d in delegates){
-                                               d.BeginInvoke (this, (FileSystemEventArgs) arg, null, null);
-                                       }
+                               switch (evtype) {
+                               case EventType.RenameEvent:
+                                       ((RenamedEventHandler)ev).BeginInvoke (this, (RenamedEventArgs) arg, null, null);
+                                       break;
+                               case EventType.ErrorEvent:
+                                       ((ErrorEventHandler)ev).BeginInvoke (this, (ErrorEventArgs) arg, null, null);
+                                       break;
+                               case EventType.FileSystemEvent:
+                                       ((FileSystemEventHandler)ev).BeginInvoke (this, (FileSystemEventArgs) arg, null, null);
+                                       break;
                                }
                                return;
                        }