Beispiel #1
0
        private static string BuildMessage(PropertyChangeEventArgs propertyChangeEventArgs, Type requiredType)
        {
            StringBuilder message = new StringBuilder();

            message.Append("Cannot convert property value of type [");
            if (propertyChangeEventArgs != null && propertyChangeEventArgs.NewValue != null)
            {
                message.Append(propertyChangeEventArgs.NewValue.GetType().FullName);
            }
            else
            {
                message.Append("null");
            }
            message.Append("] to required type [");
            if (requiredType != null)
            {
                message.Append(requiredType.FullName);
            }
            else
            {
                message.Append("null");
            }
            message.Append("] for property '");
            if (propertyChangeEventArgs != null && propertyChangeEventArgs.PropertyName != null)
            {
                message.Append(propertyChangeEventArgs.PropertyName);
            }
            message.Append("'.");
            return(message.ToString());
        }
 /// <summary>
 /// Constructor to use when an exception results from a
 /// <see cref="System.ComponentModel.PropertyChangedEventArgs"/>.
 /// </summary>
 /// <param name="ex">
 /// The <see cref="System.Exception"/> raised by the invoked property.
 /// </param>
 /// <param name="argument">
 /// The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> that
 /// resulted in an exception.
 /// </param>
 public MethodInvocationException(Exception ex, PropertyChangeEventArgs argument) :
     base("Property '" + argument.PropertyName + "' threw exception.", argument, ex)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Create a new instance of the PropertyAccessException class.
 /// </summary>
 /// <param name="message">
 /// A message about the exception.
 /// </param>
 /// <param name="propertyChangeEvent">Describes the change attempted on the property.</param>
 protected PropertyAccessException(string message, PropertyChangeEventArgs propertyChangeEvent) : base(message)
 {
     _propertyChangeEventArgs = propertyChangeEvent;
 }
Beispiel #4
0
 /// <summary>
 /// Creates a new instance of the PropertyAccessExceptionsException class.
 /// </summary>
 /// <param name="info">
 /// The <see cref="System.Runtime.Serialization.SerializationInfo"/>
 /// that holds the serialized object data about the exception being thrown.
 /// </param>
 /// <param name="context">
 /// The <see cref="System.Runtime.Serialization.StreamingContext"/>
 /// that contains contextual information about the source or destination.
 /// </param>
 protected PropertyAccessException(
     SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     _propertyChangeEventArgs = info.GetValue("PropertyChangeArgs", typeof(object)) as PropertyChangeEventArgs;
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new instance of the TypeMismatchException class describing the
 /// property and required type that could not used to set a property on the target object.
 /// </summary>
 /// <param name="propertyChangeEventArgs">
 /// The description of the property that was to be changed.
 /// </param>
 /// <param name="requiredType">The target conversion type.</param>
 public TypeMismatchException(
     PropertyChangeEventArgs propertyChangeEventArgs, Type requiredType) :
     base(BuildMessage(propertyChangeEventArgs, requiredType), propertyChangeEventArgs)
 {
 }