public static void Watch(string path, WatcherType watcherType, WatchAction action) { var watcher = new FileWatcher(Path.GetFullPath(path), watcherType, action) { Watching = true }; Watchers.Add(watcher); }
public static void Watch(string path, WatcherType watcherType, WatchAction action) { FileWatcher item = new FileWatcher(Path.GetFullPath(path), watcherType, action) { Watching = true }; FileWatcherManager.Watchers.Add(item); }
public FileWatcher(string path, WatcherType type, WatchAction action) : base(System.IO.Path.GetDirectoryName(path)) { this.FullPath = System.IO.Path.GetFullPath(path); this.Type = type; this.Action = action; if (path.EndsWith(System.IO.Path.AltDirectorySeparatorChar.ToString()) || path.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { base.IncludeSubdirectories = true; } base.Deleted += new FileSystemEventHandler(this.OnDeleted); base.Created += new FileSystemEventHandler(this.OnCreated); base.Changed += new FileSystemEventHandler(this.OnChanged); base.EnableRaisingEvents = true; }
public bool ChangeWatchAction(ulong guildId, long forumUserId, WatchAction watchAction) { var wfa = GetForGuild(guildId).FirstOrDefault(m => m.ForumUserId == forumUserId); if (wfa is not null) { wfa.WatchAction = watchAction; return(true); } else { return(false); } }
public bool Create(ulong guildId, long forumUserId, WatchAction watchAction) { if (_set.FirstOrDefault(wfa => wfa.GuildId == guildId && wfa.ForumUserId == forumUserId) is null) { _set.Add(new WatchedForumAccount { GuildId = guildId, ForumUserId = forumUserId, WatchAction = watchAction, }); return(true); } else { return(false); } }
public FileWatcher(string path, WatcherType type, WatchAction action) : base(System.IO.Path.GetDirectoryName(path)) { FullPath = System.IO.Path.GetFullPath(path); Type = type; Action = action; // it's a directory so we add the sub dirs if (path.EndsWith(System.IO.Path.AltDirectorySeparatorChar.ToString()) || path.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { IncludeSubdirectories = true; } Deleted += OnDeleted; Created += OnCreated; Changed += OnChanged; EnableRaisingEvents = true; }