示例#1
0
        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);
        }
示例#3
0
 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;
 }
示例#4
0
        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);
            }
        }
示例#5
0
        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);
            }
        }
示例#6
0
        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;
        }