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(String.Format("One of the properties in the expression '{0}' was null", This.GetPropertyName()));
            }
            return(ret);
        }
        internal static IObservedChange <TSender, TValue> fillInValue <TSender, TValue>(this IObservedChange <TSender, TValue> This)
        {
            // XXX: This is an internal method because I'm unsafely upcasting,
            // but in certain cases it's needed.
            var ret = (ObservedChange <TSender, TValue>)This;
            var val = default(TValue);

            This.TryGetValue(out val);
            ret.Value = val;
            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="this">
        /// 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> @this)
        {
            TValue ret;

            if ([email protected](out ret))
            {
                throw new Exception($"One of the properties in the expression '{@this.GetPropertyName()}' was null");
            }

            return(ret);
        }