internal void SetConsumerValue <T>(ref T field, T newValue, [CallerMemberName] string propertyName = null) { if (!GenericCompare.Equals(field, newValue)) { field = newValue; this.HasChanges = true; this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); } }
protected bool SetValue <T>(ref T field, T newValue, [CallerMemberName] string propertyName = null) { var result = !GenericCompare.Equals(field, newValue); if (result) { field = newValue; this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); } return(result); }
/// <summary>Waits until <paramref name="property"/> has the value <paramref name="expected"/>.</summary> /// <typeparam name="TOwner">The type of the owner object.</typeparam> /// <typeparam name="TProperty">The type of the property.</typeparam> /// <returns>The new value of the property.</returns> public static async Task <TProperty> WaitForChangeAsync <TOwner, TProperty>( IProperty <TOwner, TProperty> property, TProperty expected) where TOwner : INotifyPropertyChanged { Predicate <TProperty> predicate = v => GenericCompare.Equals(expected, v); if (predicate(property.Value)) { return(property.Value); } while (!predicate(await WaitForChangeAsync(property))) { } return(property.Value); }
public void GenericCompare_Test() { var obj1 = new TestClass { Value1 = true, Value2 = "test3", Date1 = new DateTime(2017, 12, 31) }; var obj2 = new TestClass { Value1 = true, Value2 = "test4", Date1 = new DateTime(2017, 12, 31) }; var compareValue1 = new GenericCompare <TestClass>(test => test.Value1); var compareValue2 = new GenericCompare <TestClass>(test => test.Value2); var compareDate1 = new GenericCompare <TestClass>(test => test.Date1); Assert.True(compareValue1.Equals(obj1, obj2), "compareValue1.Equals(obj1, obj2)"); Assert.False(compareValue2.Equals(obj1, obj2), "compareValue2.Equals(obj1, obj2)"); Assert.True(compareDate1.Equals(obj1, obj2), "compareDate1.Equals(obj1, obj2)"); }
public BinarySearchTree(IComparer <T> comparer) { _comparer = new GenericCompare <T>(comparer); }
public BinarySearchTree() { _isRefType = typeof(T).IsClass; _comparer = new GenericCompare <T>(); }
public bool Equals(Field <TTypeId, TFieldId> other) => GenericCompare.Equals(this.TypeId, other.TypeId) && GenericCompare.Equals(this.FieldId, other.FieldId);