public static void write(string s) { if (!is_enabled) { return; } if (log == null) { if (path == null || (path != null && path.Equals(""))) { path = PortUtil.createTempFile(); //path = "C:\\log.txt"; } try { log = new StreamWriter(path); log.AutoFlush = true; } catch (Exception ex) { serr.println("Logger#write; ex=" + ex); } } if (log == null) { return; } try { log.Write(s); } catch (Exception ex) { serr.println("Logger#write; ex=" + ex); } }
public void testXmlSerialization() { XmlSerializer xs = new XmlSerializer(typeof(WaveUnitConfig)); WaveUnitConfig item = new WaveUnitConfig(); item.putElement("a", "A"); string actualPath = PortUtil.createTempFile(); using (FileStream fs = new FileStream(actualPath, FileMode.Create, FileAccess.Write)){ xs.serialize(fs, item); } Console.WriteLine(File.ReadAllText(actualPath)); byte[] actual = File.ReadAllBytes(actualPath); byte[] expected = File.ReadAllBytes("./expected/WaveUnitConfig.xml"); Assert.AreEqual(expected, actual); File.Delete(actualPath); }
public static void Main(string[] args) { Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); Thread.GetDomain().UnhandledException += new UnhandledExceptionEventHandler(Cadencii_UnhandledException); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // 引数を解釈 parseArguments(args); if (mPrintVersion) { Console.Write(BAssemblyInfo.fileVersion); return; } string file = mPathVsq; Logger.setEnabled(false); string logfile = PortUtil.createTempFile() + ".txt"; Logger.setPath(logfile); #if DEBUG Logger.setEnabled(true); #endif #if !DEBUG try { #endif // 言語設定を読み込み try { Messaging.loadMessages(); // システムのデフォルトの言語を調べる. // EditorConfigのコンストラクタは,この判定を自動でやるのでそれを利用 EditorConfig ec = new EditorConfig(); Messaging.setLanguage(ec.Language); } catch (Exception ex) { Logger.write(typeof(FormMain) + ".ctor; ex=" + ex + "\n"); serr.println("FormMain#.ctor; ex=" + ex); } // 開発版の場合の警告ダイアログ string str_minor = BAssemblyInfo.fileVersionMinor; int minor = 0; try { minor = int.Parse(str_minor); } catch (Exception ex) { } /*if ((minor % 2) != 0) { * AppManager.showMessageBox( * PortUtil.formatMessage( * _("Info: This is test version of Cadencii version {0}"), * BAssemblyInfo.fileVersionMeasure + "." + (minor + 1)), * "Cadencii_UTAU", * cadencii.windows.forms.Utility.MSGBOX_DEFAULT_OPTION, * cadencii.windows.forms.Utility.MSGBOX_INFORMATION_MESSAGE); * }*/ // スプラッシュを表示するスレッドを開始 #if !MONO splashThread = new Thread(new ThreadStart(showSplash)); splashThread.TrySetApartmentState(ApartmentState.STA); splashThread.Start(); #endif // AppManagerの初期化 AppManager.init(); #if ENABLE_SCRIPT try { ScriptServer.reload(); PaletteToolServer.init(); } catch (Exception ex) { serr.println("Cadencii::Main; ex=" + ex); Logger.write(typeof(Cadencii) + ".Main; ex=" + ex + "\n"); } #endif AppManager.mMainWindowController = new FormMainController(); AppManager.mMainWindow = new FormMain(AppManager.mMainWindowController, file); #if !MONO AppManager.mMainWindow.Load += mainWindow_Load; #endif Application.Run(AppManager.mMainWindow); #if !DEBUG } catch (Exception ex) { String str_ex = getExceptionText(ex, 0); FormCompileResult dialog = new FormCompileResult( _("Failed to launch Cadencii. Please send the exception report to developer"), str_ex); dialog.Text = _("Error"); dialog.ShowDialog(); if (splash != null) { splash.Invoke(new Action(splash.Close)); } Logger.write(typeof(Cadencii) + ".Main; ex=" + ex + "\n"); } #endif }