/// <summary> /// Initializes a new instance of the <see cref="BooleanObservableResult"/> class. /// </summary> /// <param name="result">The result.</param> public BooleanObservableResult(IObservableResult <bool> result) { _result = result; CurrentValue = _result.CurrentValue; PropertyChangedEventManager.AddListener(result, this, nameof(CurrentValue)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false. /// </returns> public bool Equals(IObservableResult <T> other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(EqualityComparer <T> .Default.Equals(CurrentValue, other.CurrentValue)); }
/// <summary> /// Initializes a new instance of the <see cref="TernaryObservableResult{TResult}"/> class. /// </summary> /// <param name="condition">The condition.</param> /// <param name="positiveResult">The positive result.</param> /// <param name="negativeResult">The negative result.</param> public TernaryObservableResult( IObservableResult <bool> condition, IObservableResult <TResult> positiveResult, IObservableResult <TResult> negativeResult) { Condition = condition; PositiveResult = positiveResult; NegativeResult = negativeResult; PropertyChangedEventManager.AddListener(Condition, this, nameof(IObservableResult <bool> .CurrentValue)); PropertyChangedEventManager.AddListener(PositiveResult, this, nameof(IObservableResult <TResult> .CurrentValue)); PropertyChangedEventManager.AddListener(NegativeResult, this, nameof(IObservableResult <TResult> .CurrentValue)); UpdateCurrentValue(); }
public ExtensionLogger(string name, IServiceProvider serviceProvider, Guid outputPaneGuid, Lazy <IObservableResult <bool> > showDiagnostics) { _traceCategory = name; _serviceProvider = serviceProvider; _outputPaneGuid = outputPaneGuid; _outputPaneCaption = "Ext: " + _traceCategory + " (Diagnostic)"; _showDiagnostics = new Lazy <IObservableResult <bool> >(() => { IObservableResult <bool> observable = showDiagnostics.Value; observable.ValueChanged += (sender, e) => { if (!((IObservableResult <bool>)sender).Value) { ClosePane(); } }; return(observable); }); }
/// <summary> /// Initializes a new instance of the <see cref="CompositeObservableResult{TFirst, TSecond, TResult}"/> class. /// </summary> /// <param name="first">The first operand.</param> /// <param name="second">The second operand.</param> /// <param name="operation">The operation.</param> /// <exception cref="System.ArgumentNullException"> /// Thrown any of the operands or the operation ar <c>null</c>. /// </exception> public CompositeObservableResult(TFirst first, IObservableResult <TSecond> second, Func <TFirst, TSecond, TResult> operation) { if (first == null) { throw new ArgumentNullException(nameof(first)); } if (second == null) { throw new ArgumentNullException(nameof(second)); } if (operation == null) { throw new ArgumentNullException(nameof(operation)); } _first = new FixedValue <TFirst>(first); _second = second; _operation = operation; CurrentValue = _operation(_first.CurrentValue, _second.CurrentValue); PropertyChangedEventManager.AddListener(_second, this, nameof(CurrentValue)); }
/// <summary> /// Initializes a new instance of the <see cref="InvertedBooleanObservableResult"/> class. /// </summary> /// <param name="result">The result.</param> public InvertedBooleanObservableResult(IObservableResult <bool> result) : base(result) { CurrentValue = !result.CurrentValue; }