Exemplo n.º 1
0
 public static void Remove(RemoteDefinition definition)
 {
     if (_definitions.Remove(definition))
     {
         string path              = Path.GetFullPath(definition.Path);
         string directory         = Path.GetDirectoryName(path);
         bool   removeFileWatcher = true;
         foreach (var existingDefinition in _definitions)
         {
             string existingDefPath      = Path.GetFullPath(existingDefinition.Path);
             string existingDefDirectory = Path.GetDirectoryName(existingDefPath);
             if (directory.Equals(existingDefDirectory, StringComparison.OrdinalIgnoreCase))
             {
                 removeFileWatcher = false;
                 break;
             }
         }
         if (removeFileWatcher)
         {
             if (_filewatchers.TryGetValue(directory, out FileSystemWatcher watcher))
             {
                 watcher.EnableRaisingEvents = false;
                 watcher.Dispose();
                 _filewatchers.Remove(directory);
             }
         }
     }
 }
Exemplo n.º 2
0
        public static RemoteDefinition Create(string path, HopsComponent parentComponent)
        {
            var rc = new RemoteDefinition(path, parentComponent);

            RemoteDefinitionCache.Add(rc);
            return(rc);
        }
Exemplo n.º 3
0
 public static void Add(RemoteDefinition definition)
 {
     if (definition.PathIsAppServer)
     {
         return;
     }
     if (!File.Exists(definition.Path))
     {
         return;
     }
     if (_definitions.Contains(definition))
     {
         return;
     }
     _definitions.Add(definition);
     RegisterFileWatcher(definition.Path);
 }
 public static void Add(RemoteDefinition definition)
 {
     // we are only interested in caching definitions which reference
     // gh/ghx files so we can use file watchers to make sure everything
     // is in sync
     if (definition.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
     {
         return;
     }
     if (!File.Exists(definition.Path))
     {
         return;
     }
     if (_definitions.Contains(definition))
     {
         return;
     }
     _definitions.Add(definition);
     RegisterFileWatcher(definition.Path);
 }