void InitWatcher()
        {
            lock (lockobj)
            {
                if (watcher != null)
                {
                    return;
                }

                string managed = Environment.GetEnvironmentVariable("MONO_MANAGED_WATCHER");
                int    mode    = 0;
                if (managed == null)
                {
                    mode = InternalSupportsFSW();
                }

                bool ok = false;
                switch (mode)
                {
                case 1: // windows
                    ok = DefaultWatcher.GetInstance(out watcher);
                    //ok = WindowsWatcher.GetInstance (out watcher);
                    break;

                case 2: // libfam
                    ok = FAMWatcher.GetInstance(out watcher, false);
                    break;

                case 3: // kevent
                    ok = KeventWatcher.GetInstance(out watcher);
                    break;

                case 4: // libgamin
                    ok = FAMWatcher.GetInstance(out watcher, true);
                    break;

                case 5: // inotify
                    ok = InotifyWatcher.GetInstance(out watcher, true);
                    break;
                }

                if (mode == 0 || !ok)
                {
                    if (String.Compare(managed, "disabled", true) == 0)
                    {
                        NullFileWatcher.GetInstance(out watcher);
                    }
                    else
                    {
                        DefaultWatcher.GetInstance(out watcher);
                    }
                }

                ShowWatcherInfo();
            }
        }
Example #2
0
        private void InitWatcher()
        {
            object obj = FileSystemWatcher.lockobj;

            lock (obj)
            {
                if (FileSystemWatcher.watcher == null)
                {
                    string environmentVariable = Environment.GetEnvironmentVariable("MONO_MANAGED_WATCHER");
                    int    num = 0;
                    if (environmentVariable == null)
                    {
                        num = FileSystemWatcher.InternalSupportsFSW();
                    }
                    bool flag = false;
                    switch (num)
                    {
                    case 1:
                        flag = DefaultWatcher.GetInstance(out FileSystemWatcher.watcher);
                        break;

                    case 2:
                        flag = FAMWatcher.GetInstance(out FileSystemWatcher.watcher, false);
                        break;

                    case 3:
                        flag = KeventWatcher.GetInstance(out FileSystemWatcher.watcher);
                        break;

                    case 4:
                        flag = FAMWatcher.GetInstance(out FileSystemWatcher.watcher, true);
                        break;

                    case 5:
                        flag = InotifyWatcher.GetInstance(out FileSystemWatcher.watcher, true);
                        break;
                    }
                    if (num == 0 || !flag)
                    {
                        if (string.Compare(environmentVariable, "disabled", true) == 0)
                        {
                            NullFileWatcher.GetInstance(out FileSystemWatcher.watcher);
                        }
                        else
                        {
                            DefaultWatcher.GetInstance(out FileSystemWatcher.watcher);
                        }
                    }
                }
            }
        }
Example #3
0
        void InitWatcher()
        {
            lock (lockobj) {
                if (watcher_handle != null)
                {
                    return;
                }

                string managed = Environment.GetEnvironmentVariable("MONO_MANAGED_WATCHER");
                int    mode    = 0;
                if (managed == null)
                {
                    mode = InternalSupportsFSW();
                }

                bool ok = false;
                switch (mode)
                {
                case 1:                 // windows
                    ok             = DefaultWatcher.GetInstance(out watcher);
                    watcher_handle = this;
                    break;

                case 2:                 // libfam
                    ok             = FAMWatcher.GetInstance(out watcher, false);
                    watcher_handle = this;
                    break;

                case 3:                 // kevent
                    ok             = KeventWatcher.GetInstance(out watcher);
                    watcher_handle = this;
                    break;

                case 4:                 // libgamin
                    ok             = FAMWatcher.GetInstance(out watcher, true);
                    watcher_handle = this;
                    break;

                case 6:                 // CoreFX
                    ok             = CoreFXFileSystemWatcherProxy.GetInstance(out watcher);
                    watcher_handle = (watcher as CoreFXFileSystemWatcherProxy).NewWatcher(this);
                    break;
                }

                if (mode == 0 || !ok)
                {
                    if (String.Compare(managed, "disabled", true) == 0)
                    {
                        NullFileWatcher.GetInstance(out watcher);
                    }
                    else
                    {
                        DefaultWatcher.GetInstance(out watcher);
                        watcher_handle = this;
                    }
                }
                this.inited = true;

                ShowWatcherInfo();
            }
        }