static public void InvokeInParseCulture(this Action Method) { var OriginalCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = ParseCulture; try { Method?.Invoke(); } finally { Thread.CurrentThread.CurrentCulture = OriginalCulture; } }
/// <summary> /// Raises event with thread and null-ref safety. /// </summary> public static void Raise(this Action handler) { handler?.Invoke(); }
/// <summary>指定されたインスタンスおよびプロパティ名を使用して、<see cref="INotifyPropertyChanged.PropertyChanged"/> イベントを発生させます。</summary> /// <param name="handler"><see cref="INotifyPropertyChanged.PropertyChanged"/> イベントを発生させるデリゲートを指定します。</param> /// <param name="this"><see cref="INotifyPropertyChanged.PropertyChanged"/> イベントを発生させるインスタンスを指定します。</param> /// <param name="propertyName">変更されたプロパティの名前を指定します。省略した場合はこのメソッドが呼び出されたプロパティの名前が使用されます。</param> public static void Raise(this PropertyChangedEventHandler handler, object @this, [CallerMemberName]string propertyName = "") { handler?.Invoke(@this, new PropertyChangedEventArgs(propertyName)); }
/// <summary> /// if e != null, call e() with propertyName /// </summary> /// <param name="e"></param> /// <param name="sender"></param> /// <param name="propertyName"></param> public static void Fire(this PropertyChangedEventHandler e, object sender, string propertyName) { e?.Invoke(sender, new PropertyChangedEventArgs(propertyName)); }
public static void Raise(this EventHandler handler, object sender, EventArgs e) { handler?.Invoke(sender, e); }
public static void Raise(this EventHandler evnt, object sender = null) => evnt?.Invoke(sender, EventArgs.Empty);