Example #1
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);
                        }
                    }
                }
            }
        }