public void StorageFiresEventTest() { using (ConfigurationContext configurationContext = CreateConfigurationContext(XmlString)) { StorageProviderFactory factory = new StorageProviderFactory(configurationContext); IStorageProviderReader storage = factory.Create(applConfig1) as IStorageProviderReader; Assert.AreSame(storage.GetType(), typeof(XmlFileStorageProvider)); using (IConfigurationChangeWatcher watcher = storage.CreateConfigurationChangeWatcher()) { watcher.ConfigurationChanged += new ConfigurationChangedEventHandler(OnConfigurationChanged); watcher.StartWatching(); Thread.Sleep(100); ((IStorageProviderWriter)storage).Write(GetData()); for (int wait = 0; wait < 10 && eventFiredCount < 2; ++wait) { Thread.Sleep(500); } watcher.Dispose(); } Assert.AreEqual(1, eventFiredCount); } }
public void Dispose() { if (watcher != null) { watcher.StartWatching(); } }
private void CreateMetaConfigChangeWatcher() { if (metaConfigChangeWatcher != null) { metaConfigChangeWatcher.Dispose(); } metaConfigChangeWatcher = configFile.CreateFileWatcher(); metaConfigChangeWatcher.ConfigurationChanged += new ConfigurationChangedEventHandler(OnMetaConfigurationChanged); metaConfigChangeWatcher.StartWatching(); }
public void StorageFiresEventTest() { string filename = Path.GetFullPath(myConfigTestFile); bool fileExists = File.Exists(filename); Assert.IsTrue(fileExists); bool loaded = configFile.Load(filename); Assert.IsTrue(loaded); using (IConfigurationChangeWatcher watcher = configFile.CreateFileWatcher()) { ((ConfigurationChangeFileWatcher)watcher).SetPollDelayInMilliseconds(100); watcher.ConfigurationChanged += new ConfigurationChangedEventHandler(OnConfigurationChanged); watcher.StartWatching(); Thread.Sleep(150); FileUtility.OpenAndChangeFile(myConfigTestFile); for (int wait = 0; wait < 10 && eventFiredCount == 0; ++wait) { Thread.Sleep(500); } } Assert.AreEqual(1, eventFiredCount); }
private void CreateMetaConfigChangeWatcher() { if (metaConfigChangeWatcher != null) { metaConfigChangeWatcher.Dispose(); } metaConfigChangeWatcher = configFile.CreateFileWatcher(); metaConfigChangeWatcher.ConfigurationChanged += new ConfigurationChangedEventHandler(OnMetaConfigurationChanged); metaConfigChangeWatcher.StartWatching(); }
private void AddConfigurationWatcherForSection(ConfigurationChangedEventHandler changed, IConfigurationChangeWatcher watcher) { watcher.ConfigurationChanged += changed; watcher.StartWatching(); ConfigurationWatcherCache.Add(watcher.SectionName, watcher); }
private void AddConfigurationWatcherForSection(ConfigurationChangedEventHandler changed, IConfigurationChangeWatcher watcher) { watcher.ConfigurationChanged += changed; watcher.StartWatching(); ConfigurationWatcherCache.Add(watcher.SectionName, watcher); }