Exemple #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void startWatching() throws InterruptedException
        public override void StartWatching()
        {
            _watch = true;
            while (_watch)
            {
                WatchKey key = _watchService.take();
                if (key != null)
                {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<java.nio.file.WatchEvent<?>> watchEvents = key.pollEvents();
                    IList <WatchEvent <object> > watchEvents = key.pollEvents();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: for (java.nio.file.WatchEvent<?> watchEvent : watchEvents)
                    foreach (WatchEvent <object> watchEvent in watchEvents)
                    {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.nio.file.WatchEvent.Kind<?> kind = watchEvent.kind();
                        WatchEvent.Kind <object> kind = watchEvent.kind();
                        if (StandardWatchEventKinds.ENTRY_MODIFY == kind)
                        {
                            NotifyAboutModification(watchEvent);
                        }
                        if (StandardWatchEventKinds.ENTRY_DELETE == kind)
                        {
                            NotifyAboutDeletion(watchEvent);
                        }
                    }
                    key.reset();
                }
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.io.fs.watcher.resource.WatchedResource watch(java.io.File file) throws java.io.IOException
        public override WatchedResource Watch(File file)
        {
            if (!file.Directory)
            {
                throw new System.ArgumentException(format("File `%s` is not a directory. Only directories can be " + "registered to be monitored.", file.CanonicalPath));
            }
            WatchKey watchKey = file.toPath().register(_watchService, _observedEvents, SensitivityWatchEventModifier.HIGH);

            return(new WatchedFile(watchKey));
        }
Exemple #3
0
 public WatchedFile(WatchKey watchKey)
 {
     this._watchKey = watchKey;
 }