Beispiel #1
0
        /// <summary>
        /// Tries to cast a value to a type, taking into account that the value may be a
        /// <see cref="BindingNotification"/>.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="type">The type.</param>
        /// <returns>The cast value, or a <see cref="BindingNotification"/>.</returns>
        private static object CastOrDefault(object value, Type type)
        {
            var notification = value as BindingNotification;

            if (notification == null)
            {
                return(TypeUtilities.ConvertImplicitOrDefault(value, type));
            }
            else
            {
                if (notification.HasValue)
                {
                    notification.SetValue(TypeUtilities.ConvertImplicitOrDefault(notification.Value, type));
                }

                return(notification);
            }
        }