コード例 #1
0
 internal void Trigger(InternalEvent internalEvent)
 {
     EventManager em;
     if (events.TryGetValue(internalEvent, out em))
     {
         em.Pending = 1;
     }
 }
コード例 #2
0
 public EventManager([NotNull] InternalEvent internalEvent, TimeSpan betweenDelay, [NotNull] Func<Message> messageFactory)
 {
     if (internalEvent == null)
         throw new ArgumentNullException(nameof(internalEvent));
     if (messageFactory == null)
         throw new ArgumentNullException(nameof(messageFactory));
     InternalEvent = internalEvent;
     BetweenDelay = betweenDelay;
     MessageFactory = messageFactory;
 }
コード例 #3
0
        internal WurmCharacterLogFiles([NotNull] CharacterName characterName, [NotNull] string fullDirPathToCharacterLogsDir, [NotNull] ILogger logger, [NotNull] LogFileInfoFactory logFileInfoFactory, [NotNull] IInternalEventInvoker internalEventInvoker,
            [NotNull] TaskManager taskManager)
        {
            if (characterName == null) throw new ArgumentNullException("characterName");
            if (fullDirPathToCharacterLogsDir == null) throw new ArgumentNullException("fullDirPathToCharacterLogsDir");
            if (logger == null) throw new ArgumentNullException("logger");
            if (logFileInfoFactory == null) throw new ArgumentNullException("logFileInfoFactory");
            if (internalEventInvoker == null) throw new ArgumentNullException("internalEventInvoker");
            if (taskManager == null) throw new ArgumentNullException("taskManager");
            this.logger = logger;
            this.logFileInfoFactory = logFileInfoFactory;
            this.taskManager = taskManager;
            CharacterName = characterName;
            FullDirPathToCharacterLogsDir = fullDirPathToCharacterLogsDir;

            onFilesAddedOrRemoved = internalEventInvoker.Create(() => new CharacterLogFilesAddedOrRemoved(CharacterName));

            try
            {
                Refresh();
            }
            catch (Exception exception)
            {
                logger.Log(LogLevel.Error, "Error at initial WurmCharacterLogFiles refresh: " + CharacterName, this, exception);
            }

            directoryWatcher = new FileSystemWatcher(fullDirPathToCharacterLogsDir)
            {
                Filter = "*.txt",
                NotifyFilter = NotifyFilters.FileName
            };
            directoryWatcher.Created += DirectoryWatcherOnChanged;
            directoryWatcher.Deleted += DirectoryWatcherOnChanged;
            directoryWatcher.Renamed += DirectoryWatcherOnChanged;
            directoryWatcher.Changed += DirectoryWatcherOnChanged;

            directoryWatcher.EnableRaisingEvents = true;

            taskHandle = new TaskHandle(Refresh, "WurmCharacterLogFiles refresh: " + CharacterName);
            taskManager.Add(taskHandle);

            taskHandle.Trigger();
        }
コード例 #4
0
 internal void Detach(InternalEvent internalEvent)
 {
     EventManager em;
     events.TryRemove(internalEvent, out em);
 }