public override void TryReload(FileSystemWatcherManager sender, FileSystemWatcherManager.ReloadArgs e) { LevelSettings settings = Parent.Settings; if (settings == null) { return; } ImportedGeometryTexture importedGeometryTextureReloaded = new ImportedGeometryTexture(ImportedGeometryTexture.AbsolutePath); Parent.SynchronizationContext.Post(unused => { ImportedGeometryTexture.Assign(importedGeometryTextureReloaded); Parent?.ImportedGeometryTexturesChanged(null, new ChangedEventArgs <ImportedGeometryTexture> { Object = ImportedGeometryTexture }); }, null); }
public override void TryReload(FileSystemWatcherManager sender, FileSystemWatcherManager.ReloadArgs e) { LevelSettings settings = Parent.Settings; if (settings == null) { return; } var textureTemp = (LevelTexture)(Texture.Clone()); textureTemp.Reload(settings); Parent.SynchronizationContext.Post(unused => { Texture.Assign(textureTemp); Parent.TextureChanged(null, new ChangedEventArgs <LevelTexture> { Object = Texture }); }, null); }
public override void TryReload(FileSystemWatcherManager sender, FileSystemWatcherManager.ReloadArgs e) { LevelSettings settings = Parent.Settings; if (settings == null) { return; } ReferencedSoundsCatalog newCatalog = SoundsCatalog.Clone(); newCatalog.Reload(settings); Parent.SynchronizationContext.Post(unused => { SoundsCatalog.Assign(newCatalog); Parent?.SoundsCatalogChanged(null, new ChangedEventArgs <ReferencedSoundsCatalog> { Object = newCatalog }); }, null); }
public override void TryReload(FileSystemWatcherManager sender, FileSystemWatcherManager.ReloadArgs e) { LevelSettings settings = Parent.Settings; if (settings == null) { return; } ReferencedWad newWad = Wad.Clone(); newWad.Reload(settings); Parent.SynchronizationContext.Post(unused => { Wad.Assign(newWad); Parent?.WadChanged(null, new ChangedEventArgs <ReferencedWad> { Object = newWad }); }, null); }
public override void TryReload(FileSystemWatcherManager sender, FileSystemWatcherManager.ReloadArgs e) { LevelSettings settings = Parent.Settings; if (settings == null) { return; } Parent.SynchronizationContext.Send(unused => { // It would be very nice if we could do this concurrently. // However we can't because reloading depends on the entire level settings :( settings.ImportedGeometryUpdate(ImportedGeometry, ImportedGeometry.Info); }, null); Parent.SynchronizationContext.Post(unused => { Parent?.ImportedGeometryChanged(null, new ChangedEventArgs <ImportedGeometry> { Object = ImportedGeometry }); }, null); }
public void FileSystemWatcherManagerTest() { var pwd = Directory.GetCurrentDirectory(); var dest = pwd + @"\test"; if (Directory.Exists(dest)) { Directory.Delete(dest, true); } Directory.CreateDirectory(dest); string[] exts = { "hoge", "fuga", "txt" }; fswm = new FileSystemWatcherManager(pwd, dest, exts); var timeStr = AutoBackup.GetTimeString(); var input = "hogefuga" + timeStr; System.IO.StreamWriter sw = new System.IO.StreamWriter( pwd + @"\test.txt", false, System.Text.Encoding.GetEncoding("shift_jis")); //TextBox1.Textの内容を書き込む sw.Write(input); //閉じる sw.Close(); Console.WriteLine(pwd); System.Threading.Thread.Sleep(6000); var fileName = Directory.GetFiles(pwd + @"\test")[0]; StreamReader sr = new StreamReader(fileName, System.Text.Encoding.GetEncoding("shift_jis")); var output = sr.ReadToEnd(); sr.Close(); Assert.AreEqual(input, output); }
private void LoadConfigs(IEnumerable <Platform> platforms) { foreach (var platform in platforms.Where(p => p.Active).ToList()) { var configPath = HostingEnvironment.ApplicationPhysicalPath != null // Normal flow (IIS) ? Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "Configuration\\" + platform.Name) // Determinig the not normal execution channel. : AppDomain.CurrentDomain .BaseDirectory.IndexOf ("MyHerbalife3.Ordering.Web.Test", System.StringComparison .Ordinal) > 0 // For local unit tests. ? Path.Combine( AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain .BaseDirectory .IndexOf ("MyHerbalife3.Ordering.Web.Test", System .StringComparison .Ordinal)), "MyHerbalife3.Ordering.Web\\Configuration\\" + platform.Name) // For automated test when building a check-in. : string.Concat( AppDomain.CurrentDomain.BaseDirectory, "\\_PublishedWebsites\\MyHerbalife3.Ordering.Web\\Configuration\\", platform.Name); FileSystemWatcherManager.FileChanged += new EventHandler <FileNotifyEventArgs>(ConfigFileChanged); if (!Directory.Exists(configPath)) { continue; } var configFiles = GetConfigFiles(configPath); Trace.TraceInformation( string.Format( "Begin loading configs for MyHerbalife website using Platform: {0}. Config Directory: {1}.\r\nThe following Config files will be loaded:\r\n{2}", platform.Name, configPath, GetConfigFilesList(configFiles)), "ConfigManager"); try { foreach (string configFile in configFiles) { if (ProcessConfigFile(platform.Name, configFile, false)) { FileSystemWatcherManager.AddWatchedObject(configFile); } else { _errorLoading = true; } } } catch (Exception ex) { Trace.TraceError( string.Format( "An exception occurred while initializing MyHerbalife configurations for Platform: {0}!\r\n{1}\r\n{2}", platform.Name, ex.Message, ex.StackTrace), "ConfigManager"); _errorLoading = true; } finally { if (_errorLoading) { Trace.TraceError( string.Format( "Config loading for Platform: {0} completed with errors! Review previous error messages for the details.\r\n{1}", platform.Name, _ConfigStatusMessage), "ConfigManager"); } else { Trace.TraceInformation( string.Format( "All Configs loaded successfully and without errors for Platform: {0}!\r\n{1}", platform.Name, _ConfigStatusMessage), "ConfigManager"); } _ConfigStatusMessage = new StringBuilder(); } } }