/* ----------------------------------------------------------------- */ /// /// Configure /// /// <summary> /// Sets the PowerModeContext object. /// </summary> /// /// <remarks> /// プログラム上で独自に Power.Mode の状態を更新する必要がある /// 場合などに利用します。 /// </remarks> /// /* ----------------------------------------------------------------- */ public static void Configure(PowerModeContext context) { Debug.Assert(context != null); Interlocked.Exchange(ref _context, context).PropertyChanged -= WhenPropertyChanged; context.PropertyChanged -= WhenPropertyChanged; context.PropertyChanged += WhenPropertyChanged; }
/* ----------------------------------------------------------------- */ /// /// Power /// /// <summary> /// Initializes a static fields of the Power class. /// </summary> /// /* ----------------------------------------------------------------- */ static Power() { _context = new PowerModeContext(PowerModes.Resume); _context.PropertyChanged += WhenPropertyChanged; _initializer = new OnceInitializer( () => SystemEvents.PowerModeChanged += WhenModeChanged, () => SystemEvents.PowerModeChanged -= WhenModeChanged ); }
/* ----------------------------------------------------------------- */ /// /// Configure /// /// <summary> /// Sets the PowerModeContext object. /// </summary> /// /// <remarks> /// プログラム上で独自に Power.Mode の状態を更新する必要がある /// 場合などに利用します。 /// </remarks> /// /* ----------------------------------------------------------------- */ public static void Configure(PowerModeContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Interlocked.Exchange(ref _context, context).PropertyChanged -= WhenPropertyChanged; context.PropertyChanged -= WhenPropertyChanged; context.PropertyChanged += WhenPropertyChanged; }
/* ----------------------------------------------------------------- */ /// /// Power /// /// <summary> /// Initializes a static fields of the Power class. /// </summary> /// /* ----------------------------------------------------------------- */ static Power() { _context = new PowerModeContext(PowerModes.Resume); _context.PropertyChanged += WhenPropertyChanged; SystemEvents.PowerModeChanged += WhenModeChanged; }