Beispiel #1
0
        /// <summary>
        /// Creates the specified owner.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="propertyExpression">The property expression.</param>
        /// <returns>The Property Observer.</returns>
        public static PropertyObserver <TParameter1, TResult> Create(
            [NotNull] TParameter1 owner,
            [NotNull] Expression <Func <TParameter1, TResult> > propertyExpression)
        {
            var instance = new PropertyObserver <TParameter1, TResult>(owner, propertyExpression);

            instance.Subscribe();
            return(instance);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="PropertyObserver{TResult}" /> class.
        /// </summary>
        /// <param name="propertyExpression">The property expression.</param>
        /// <exception cref="ArgumentNullException">propertyExpression is null.</exception>
        private PropertyObserver([NotNull] Expression <Func <TResult> > propertyExpression)
        {
            if (propertyExpression == null)
            {
                throw new ArgumentNullException(nameof(propertyExpression));
            }

            this.Observer           = PropertyObserver.Observes(propertyExpression, () => this.Update.Raise(), false);
            this.PropertyExpression = this.Observer.ExpressionString;
        }
Beispiel #3
0
        public static PropertyObserver <TType> Create <TType>([NotNull] Expression <Func <TType> > propertyExpression)
        {
            if (propertyExpression == null)
            {
                throw new ArgumentNullException(nameof(propertyExpression));
            }
            var instance = new PropertyObserver <TType>(propertyExpression);

            instance.Subscribe();
            return(instance);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyValueObserver{TParameter,TResult}" /> class.
        /// </summary>
        /// <param name="parameter1">The parameter1.</param>
        /// <param name="parameter2">The parameter2.</param>
        /// <param name="propertyExpression">The property expression.</param>
        /// <exception cref="ArgumentNullException">parameter1
        /// or
        /// propertyExpression</exception>
        public PropertyObserver([NotNull] TParameter1 parameter1, [NotNull] TParameter2 parameter2,
                                Expression <Func <TParameter1, TParameter2, TResult> > propertyExpression)
        {
            this.Parameter1 = parameter1 ?? throw new ArgumentNullException(nameof(parameter1));
            this.Parameter2 = parameter2 ?? throw new ArgumentNullException(nameof(parameter2));

            if (propertyExpression == null)
            {
                throw new ArgumentNullException(nameof(propertyExpression));
            }

            this.Observer =
                PropertyObserver.Observes(parameter1, parameter2, propertyExpression, () => this.Update.Raise());
            this.PropertyExpression = Observer.ExpressionString;
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertyObserver{TParameter,TResult}" /> class.
        /// </summary>
        /// <param name="parameter">The owner.</param>
        /// <param name="propertyExpression">The property expression.</param>
        /// <exception cref="ArgumentNullException">
        /// parameter1 or propertyExpression is null.
        /// </exception>
        public PropertyObserver(TParameter1 parameter, Expression <Func <TParameter1, TResult> > propertyExpression)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            if (propertyExpression == null)
            {
                throw new ArgumentNullException(nameof(propertyExpression));
            }

            this.Parameter          = parameter;
            this.Observer           = PropertyObserver.Observes(parameter, propertyExpression, () => this.Update.Raise(), false);
            this.PropertyExpression = this.Observer.ExpressionString;
        }
 /// <summary>
 /// Observeses the property.
 /// </summary>
 /// <typeparam name="TParameter">The type of the owner.</typeparam>
 /// <typeparam name="TResult">The type of the result.</typeparam>
 /// <param name="parameter">The parameter.</param>
 /// <param name="propertyExpression">The property expression.</param>
 /// <returns>
 /// Result of ObservesProperty as PropertyObserver&lt;TParameter, TResult&gt;.
 /// </returns>
 public PropertyObserver <TParameter, TResult> ObservesProperty <TParameter, TResult>(
     TParameter parameter,
     Expression <Func <TParameter, TResult> > propertyExpression)
     where TParameter : INotifyPropertyChanged
     where TResult : struct =>
 PropertyObserver <TParameter, TResult> .Create(parameter, propertyExpression);
 /// <summary>
 ///     Observeses the property.
 /// </summary>
 /// <typeparam name="TResult">The type of the type.</typeparam>
 /// <param name="propertyExpression">The property expression.</param>
 /// <returns>The PropertyObserver.</returns>
 public PropertyObserver <TResult> ObservesProperty <TResult>(
     Expression <Func <TResult> > propertyExpression) =>
 PropertyObserver <TResult> .Create(propertyExpression);