Beispiel #1
0
        /// <summary>
        ///     Returns the current value of a property given a notification that
        ///     it has changed.
        /// </summary>
        /// <returns>The current value of the property</returns>
        public static TValue GetValue <TSender, TValue>(this IObservedChange <TSender, TValue> This)
        {
            TValue ret;

            if (!This.TryGetValue(out ret))
            {
                throw new Exception($"One of the properties in the expression '{This.GetPropertyName()}' was null");
            }
            return(ret);
        }
        /// <summary>
        /// Returns the current value of a property given a notification that
        /// it has changed.
        /// </summary>
        /// <typeparam name="TSender">The sender.</typeparam>
        /// <typeparam name="TValue">The changed value.</typeparam>
        /// <param name="item">
        /// The <see cref="IObservedChange{TSender, TValue}"/> instance to get the value of.
        /// </param>
        /// <returns>
        /// The current value of the property.
        /// </returns>
        public static TValue GetValue <TSender, TValue>(this IObservedChange <TSender, TValue> item)
        {
            if (item is null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (!item.TryGetValue(out var returnValue))
            {
                throw new Exception($"One of the properties in the expression '{item.GetPropertyName()}' was null");
            }

            return(returnValue);
        }