public frmMain() { InitializeComponent(); cmbCompareMethods.DataSource = ComparatorFactory.GetAllComparators(); cmbCompareMethods.SelectedIndex = 0; }
protected virtual bool IsValueChanged(string propertyName) { var prop = DbEntry.Property(propertyName); var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType; object originalValue = OriginalValue(propertyName); object currentValue = CurrentValue(propertyName); Comparator comparator = ComparatorFactory.GetComparator(propertyType); var changed = (StateOfEntity() == EntityState.Modified && prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue)); if ((Type)propertyType == typeof(Byte[]) && changed) { if (!((IStructuralEquatable)originalValue).Equals(currentValue, StructuralComparisons.StructuralEqualityComparer)) { throw new Exception("EX_UltimaActualizacion"); } else { return(false); } } return(changed); }
private IEnumerable <AuditLogDetail> CreateComplexTypeLogDetails(string propertyName) { NavigationEntry entryMember = DbEntry.Member(propertyName) as NavigationEntry; if (entryMember != null) { Type complexTypeObj = entryMember.CurrentValue.GetType(); foreach (PropertyInfo pi in complexTypeObj.GetProperties()) { string complexTypePropertyName = $"{propertyName}_{pi.Name}"; object complexTypeOrigValue = OriginalValue(propertyName); object complexTypeNewValue = CurrentValue(propertyName); object origValue = complexTypeOrigValue == null ? null : pi.GetValue(complexTypeOrigValue); object newValue = complexTypeNewValue == null ? null : pi.GetValue(complexTypeNewValue); Comparator comparator = ComparatorFactory.GetComparator(complexTypeObj); if (!comparator.AreEqual(newValue, origValue)) { yield return(new AuditLogDetail { PropertyName = complexTypePropertyName, OriginalValue = origValue?.ToString(), NewValue = newValue?.ToString(), Log = _log }); } } } }
protected virtual bool IsValueChanged(string propertyName) { if (IsComplexType(propertyName)) { var prop = DbEntry.Reference(propertyName); var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType; object originalValue = OriginalValue(propertyName); Comparator comparator = ComparatorFactory.GetComparator(propertyType); var changed = (StateOfEntity() == EntityState.Modified && prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue)); return(changed); } else { var prop = DbEntry.Property(propertyName); var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType; object originalValue = OriginalValue(propertyName); Comparator comparator = ComparatorFactory.GetComparator(propertyType); var changed = (StateOfEntity() == EntityState.Modified && prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue)); return(changed); } }
public void DecreaseMaxItemBubbleSortTests() { for (int j = 0; j < CountRepeat; j++) { var array = SorterTestsHelper.GenerateArray(Guid.NewGuid().GetHashCode()); ArraySorter.BubbleSort(array, ComparatorFactory.GetMaxItemComparer(false)); Assert.IsTrue(SorterTestsHelper.IsTrustOrder(array, arr => arr.Max(), (a, b) => a < b)); } }
public void DecreaseAmountBubbleSortIComparerTests() { for (int j = 0; j < CountRepeat; j++) { var array = SorterTestsHelper.GenerateArray(Guid.NewGuid().GetHashCode()); ArraySorter.BubbleSort(array, ComparatorFactory.GetAmountComparisonDelegate(false)); Assert.IsTrue(SorterTestsHelper.IsTrustOrder(array, arr => arr.Sum(), (a, b) => a < b)); } }
public void IncreaseMinItemBubbleIComparerSortTests() { for (int j = 0; j < CountRepeat; j++) { var array = SorterTestsHelper.GenerateArray(Guid.NewGuid().GetHashCode()); ArraySorter.BubbleSort(array, ComparatorFactory.GetMinItemComparisonDelegate(true)); Assert.IsTrue(SorterTestsHelper.IsTrustOrder(array, arr => arr.Min(), (a, b) => a > b)); } }
protected override bool IsValueChanged(string propertyName) { var prop = DbEntry.Property(propertyName); var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType; object originalValue = OriginalValue(propertyName); Comparator comparator = ComparatorFactory.GetComparator(propertyType); var changed = prop.IsModified && !comparator.AreEqual(CurrentValue(propertyName), originalValue); return(changed); }
protected override bool IsValueChanged(string propertyName) { if (GlobalTrackingConfig.TrackEmptyPropertiesOnAdditionAndDeletion) { return(true); } var propertyType = DbEntry.Entity.GetType().GetProperty(propertyName).PropertyType; object defaultValue = propertyType.DefaultValue(); object currentValue = CurrentValue(propertyName); Comparator comparator = ComparatorFactory.GetComparator(propertyType); return(!comparator.AreEqual(defaultValue, currentValue)); }
public bool Evaluate(RuleDomain rule) { ComparatorFactory factory = new ComparatorFactory(); foreach (var condition in rule.Conditions) { var latestDevicePing = _devicePingRepository.LastDevicePingForDevice(condition.Device.DeviceId); DevicePropertyValue latestValue = latestDevicePing.DevicePropertyValues.Find( x => x.PropertyId == condition.Property.PropertyId ); if (!factory.Make(condition.ComparisonOperator).Compare(latestValue.Value, condition.ComparisonValue)) { return(false); } } return(true); }
public void BubbleSortTest_ArrayIsNull_ThrowsArgumentNullException(int[][] array) { var comparator = ComparatorFactory.GetAmountComparer(true); Assert.Throws <ArgumentNullException>(() => ArraySorter.BubbleSort(array, comparator)); }