public void Create_ValueChangedEventArgs <T>(T before, T after) { var args = ValueChangedEventArgs.Create(before, after); Assert.That(args.OldValue, Is.EqualTo(before)); Assert.That(args.NewValue, Is.EqualTo(after)); }
/// <summary> /// Attempts to change the <see cref="CurrentLanguage"/> to a new language. /// </summary> /// <param name="newLanguage">The name of the language to change to.</param> /// <returns>True if the language was successfully changed; false if the language was already set to the <paramref name="newLanguage"/> /// or the <paramref name="newLanguage"/> does not exist or is invalid.</returns> public static bool TryChangeCurrentLanguage(string newLanguage) { if (string.IsNullOrEmpty(newLanguage)) { Debug.Fail("Invalid newLanguage value."); return(false); } GameMessageCollection newLanguageCollection; // Try to create the GameMessageCollection for the new language try { newLanguageCollection = Create(newLanguage); } catch (Exception ex) { const string errmsg = "Failed to change language to `{0}`. Exception: {1}"; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, newLanguage, ex); } Debug.Fail(string.Format(errmsg, newLanguage, ex)); return(false); } // Change to the new language GameMessageCollection oldLanguage; lock (_currentLanguageSync) { // Check if we are just changing to the same language if (_currentLanguage == newLanguageCollection) { return(false); } oldLanguage = _currentLanguage; _currentLanguage = newLanguageCollection; } // Raise the event if (CurrentLanguageChanged != null) { CurrentLanguageChanged.Raise(null, ValueChangedEventArgs.Create(oldLanguage, _currentLanguage)); } return(true); }
/* ----------------------------------------------------------------- */ /// /// Load /// /// <summary> /// ユーザ設定を読み込みます。 /// </summary> /// /* ----------------------------------------------------------------- */ public void Load() => OnLoaded(ValueChangedEventArgs.Create(Value, Type.Load <TValue>(Path)));