コード例 #1
0
        public static bool GetInstance(out IFileWatcher watcher)
        {
            if (instance != null)
            {
                watcher = instance;
                return(true);
            }

            internal_map = new ConcurrentDictionary <object, C> ();
            external_map = new ConditionalWeakTable <object, M> ();
            event_map    = new ConcurrentDictionary <object, object> ();
            instance     = watcher = new CoreFXFileSystemWatcherProxy();
            return(true);
        }
コード例 #2
0
ファイル: FileSystemWatcher.cs プロジェクト: tdinucci/mono
        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);
                    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 5:                 // inotify
                    ok             = InotifyWatcher.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();
            }
        }