/// <summary> /// Initializes a new instance of the <see cref="ModuleHost"/> class. /// </summary> /// <param name="module">The Vision module to be hosted.</param> public ModuleHost(IVisionModule module) { Require.NotNull(module, nameof(module)); _messageFileWatcher = new MessageFileWatcher(module); ModuleViewModel = module.EnableModule(_messageFileWatcher); }
/// <summary> /// Initializes a new instance of the <see cref="MessageFileWatcher"/> class. /// </summary> /// <param name="module">The vision module whose message file this watcher will be monitoring.</param> public MessageFileWatcher(IVisionModule module) { Require.NotNull(module, nameof(module)); if (File.Exists(module.MessageFile)) { CurrentMessages = File.ReadAllText(module.MessageFile); } _watcher = new FileSystemWatcher { Filter = module.MessageFile, NotifyFilter = NotifyFilters.LastWrite, Path = AppContext.BaseDirectory }; _watcher.Changed += HandleMessageFileChanged; _watcher.EnableRaisingEvents = true; }