private static bool[] GetEqualComponents(Array refArray, Array newArray) { bool[] result = new bool[newArray.Length]; if (refArray != null) { for (int i = 0; i < newArray.Length; i++) { result[i] = PropertyUtils.AreEqual(newArray.GetValue(i), refArray.GetValue(i)); } } return(result); }
/// <summary> /// Sets the property value to the new value</summary> /// <param name="owner">Object whose property is set</param> /// <param name="descriptor">Property descriptor</param> /// <param name="value">New property value</param> public static void SetProperty(object owner, PropertyDescriptor descriptor, object value) { try { TypeConverter converter = descriptor.Converter; if (converter != null && value != null && converter.CanConvertFrom(value.GetType())) { value = converter.ConvertFrom(value); } bool notifyChange = false; object oldValue = null; EventHandler <PropertyEditedEventArgs> handler = PropertyEdited; if (handler != null) { oldValue = descriptor.GetValue(owner); notifyChange = !PropertyUtils.AreEqual(oldValue, value); } descriptor.SetValue(owner, value); if (notifyChange) { PropertyEditedEventArgs eventArgs = new PropertyEditedEventArgs(owner, descriptor, oldValue, value); handler(null, eventArgs); } } catch (InvalidTransactionException) { // The transaction needs to be cancelled. throw; } catch (Exception ex) { PropertyErrorEventArgs eventArgs = new PropertyErrorEventArgs(owner, descriptor, ex); PropertyError.Raise(null, eventArgs); if (!eventArgs.Cancel) { Outputs.WriteLine(OutputMessageType.Error, ex.Message); } } }
/// <summary> /// Returns whether or not the given values are equal</summary> /// <param name="value1">First value</param> /// <param name="value2">Second value</param> /// <returns>True iff the given values are equal</returns> /// <remarks>Default is to do limited deep equality testing for array types, and /// allow small errors with floating point types. Override to customize this behavior.</remarks> public virtual bool AreEqual(object value1, object value2) { return(PropertyUtils.AreEqual(value1, value2)); }