public void I18NLanguageSupport() { var tr = new ClassTextReader(typeof(I18NClassTextTestObject)); Assert.AreEqual(tr["test"], "English"); Assert.AreEqual(tr["test", "zh-CN"], "中文"); Assert.AreEqual(tr["test", "zh-SG"], "English"); }
public void DefaultTextTest() { var reader = ClassTextReader.GetReader <ClassTextTest>(); Assert.IsTrue(reader[TEST_1_KEY] == TEST_1_DFT_VALUE); Assert.IsTrue(reader[TEST_1_KEY, "zh-CN"] == "你好!我的梦!"); Assert.IsTrue(reader.Get(TEST_1_KEY) == TEST_1_DFT_VALUE); Assert.IsTrue(reader.Get(TEST_1_KEY, "zh-CN") == "你好!我的梦!"); Assert.IsTrue(reader.Get(TEST_1_KEY, "zh-cn") == "你好!我的梦!"); }
public void KeyTest() { var tr = new ClassTextReader(typeof(KeyTestObject)); Assert.AreEqual(tr["UPPER"], "1"); Assert.AreEqual(tr["lower"], "2"); Assert.AreEqual(tr["Mixed"], "3"); Assert.ThrowsException <KeyNotFoundException>(() => { _ = tr["NotFound"]; }); }
public static void Show(Window ownerWindow, AppLoadingException e) { string error_message_fmt = ClassTextReader.Read <ErrorMessageBox>("err_msg_fmt"); string error_message = string.Format(error_message_fmt, e.StepName, e.InnerException.InnerException.GetType().Name); string error_title = ClassTextReader.Read <ErrorMessageBox>("err_title"); if (MessageBox.Show(ownerWindow, error_message, error_title, MessageBoxButton.YesNoCancel, MessageBoxImage.Error) == MessageBoxResult.Yes) { try { Clipboard.SetText($"step name:{e.StepName}\nexception: {e.InnerException.InnerException}"); } catch { } } }
public static void Show(Window ownerWindow, AppLoadingException e) { ownerWindow.Dispatcher.Invoke(() => { var classTextReader = new ClassTextReader(typeof(ErrorMessageBox));//不使用缓存 string error_message_fmt = classTextReader["err_msg_fmt"]; string error_message = string.Format(error_message_fmt, e.StepName, e.InnerException.InnerException.GetType().Name); string error_title = classTextReader["err_title"]; if (MessageBox.Show(ownerWindow, error_message, error_title, MessageBoxButton.YesNoCancel, MessageBoxImage.Error) == MessageBoxResult.Yes) { try { Clipboard.SetText($"step name:{e.StepName}\nexception: {e.InnerException.InnerException}"); } catch { } } }); }
private MetricInfo VerifyExists(Metric metric) { try { bool resp = false; MetricInfo mi; string files = string.Empty; foreach (string file_dir in metric.SearchIn) { _ctr = new ClassTextReader(file_dir); var classData = _ctr.READED_CLASS; files += Path.GetFileName(file_dir) + " "; foreach (var value in metric.Value) { resp = classData.Contains(value); if (resp != true) { break; } } } mi = new MetricInfo { Name = metric.Name, Description = metric.Description, File = files, Operation = metric.Operation.ToUpper(), Result = resp }; return(mi); } catch (Exception e) { log = new Logger(); log.WriteInLog(e); return(null); } }
private ILake GetSepLake() { SunsetLake s_lake = new SunsetLake(); s_lake.RegisterSingleton <ILogger>(LoggerFactory.Auto(this.GetType().Name)); s_lake.RegisterSingleton <ClassTextReader>(() => { return(ClassTextReader.GetReader(this)); }); s_lake.RegisterSingleton <IExtensionInfo>(() => { return(this.GetExtensionInfo()); }); s_lake.RegisterSingleton <ILeafUI>(() => { ILeafUI leafUI = this.lake !.Get <ILeafUI>(); IExtensionInfo inf = this.GetExtensionInfo(); leafUI.Title = inf.Name(); leafUI.Icon = inf.Icon(); return(leafUI); }); return(s_lake); }
public void EntryPoint(INotificationManager notificationManager, ClassTextReader text, IAppManager appManager) { notificationManager.Info(text.RxGet(STR_KEY_CHECKING_UPDATE)); try { //Download&Parse remote api's infomation. var jsonString = webClient.DownloadString(URL_API); SLogger <EAutumnBoxUpdateChecker> .Info("Letest version info has been downloaded: " + jsonString); var latestVersionInfo = JsonSerializer.Deserialize <LatestVersionInfo>(jsonString); //Check if there is newer version. if (latestVersionInfo.Version > appManager.Version) { //Ask user notificationManager.Ask($"{latestVersionInfo.Title}\n{latestVersionInfo.Description}").ContinueWith(task => { if (task.Result) { appManager.OpenUrl(latestVersionInfo.DownloadUrl); } }); } else { //Everything's up to date. notificationManager.Success(text.RxGet(STR_KEY_EVERYTHING_UP_TO_DATE)); } } catch (Exception e) { SLogger <EAutumnBoxUpdateChecker> .Warn(e); notificationManager.Warn(text.RxGet(STR_KEY_FAIL)); } }
public void EntryPoint(INotificationManager notificationManager, ClassTextReader reader) { notificationManager.Info(reader[STR_KEY_CHECKING_UPDATE]); Thread.Sleep(5000); notificationManager.Warn(reader[STR_KEY_FAIL]); }
public void EntryPoint(INotificationManager notificationManager, ClassTextReader text) { notificationManager.Info(text.RxGet(STR_KEY_CHECKING_UPDATE)); Thread.Sleep(5000); notificationManager.Warn(text.RxGet(STR_KEY_FAIL)); }
static TextCarrier() { Reader = ClassTextReaderCache.Acquire <TextCarrier>(); }