private void UpdateInternal(object owner, SlimProfilerEntry entry, bool forcePropertyUpdate = false) { if (entry == null) { if (!OwnerName.Equals(_noData) || forcePropertyUpdate) { OwnerName = _noData; OnPropertyChanged(nameof(OwnerName)); } // ReSharper disable once CompareOfFloatsByEqualityOperator if (UpdateTime != 0 || forcePropertyUpdate) { UpdateTime = 0; OnPropertyChanged(nameof(UpdateTime)); } if (Children.Count > 0) { Children.Clear(); } return; } string ownerId = ProfilerObjectIdentifier.Identify(owner); if (!ownerId.Equals(OwnerName) || forcePropertyUpdate) { OwnerName = ownerId; OnPropertyChanged(nameof(OwnerName)); } UpdateTime = entry.UpdateTime; OnPropertyChanged(nameof(UpdateTime)); if (entry is FatProfilerEntry fat) { if (ChildrenSorted.IsObserved || Children.IsObserved || forcePropertyUpdate) { _childrenUpdateDeferred = false; ICollection <object> keys = fat.ChildUpdateKeys(); var id = 0; foreach (object key in keys) { if (fat.ChildUpdateTime.TryGetValue(key, out SlimProfilerEntry child) && child.UpdateTime > DisplayTimeThreshold) { if (id >= Children.Count) { var result = new ProfilerEntryViewModel(); result.UpdateInternal(key, child, forcePropertyUpdate); Children.Add(result); id++; } else { Children[id++].UpdateInternal(key, child, forcePropertyUpdate); } } } while (Children.Count > id) { Children.RemoveAt(Children.Count - 1); } using (ChildrenSorted.DeferredUpdate()) { var sortedEnumerable = Children.OrderBy(x => (int)(-x.UpdateTime / DisplayTimeThreshold)); if (Children.Count > PaginationCount) { var pageCount = (int)Math.Ceiling(Children.Count / (float)PaginationCount); if (_wasPaged) { while (ChildrenSorted.Count > pageCount) { ChildrenSorted.RemoveAt(ChildrenSorted.Count - 1); } } else { ChildrenSorted.Clear(); } while (ChildrenSorted.Count < pageCount) { ChildrenSorted.Add(new ProfilerEntryViewModel()); } using (var iterator = sortedEnumerable.GetEnumerator()) { for (var i = 0; i < pageCount; i++) { ChildrenSorted[i].OwnerName = $"Items {i * PaginationCount + 1} to {i * PaginationCount + PaginationCount}"; ChildrenSorted[i].OnPropertyChanged(nameof(OwnerName)); FillPage(ChildrenSorted[i], iterator); } } _wasPaged = true; } else { ChildrenSorted.Clear(); foreach (var k in sortedEnumerable) { ChildrenSorted.Add(k); } _wasPaged = false; } } } else { _childrenUpdateDeferred = true; } } else { Children.Clear(); ChildrenSorted.Clear(); } }
/// <summary> /// Returns true if EquipmentViewModel instances are equal /// </summary> /// <param name="other">Instance of EquipmentViewModel to be compared</param> /// <returns>Boolean</returns> public bool Equals(EquipmentViewModel other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( EquipmentType == other.EquipmentType || EquipmentType != null && EquipmentType.Equals(other.EquipmentType) ) && ( OwnerName == other.OwnerName || OwnerName != null && OwnerName.Equals(other.OwnerName) ) && ( OwnerId == other.OwnerId || OwnerId != null && OwnerId.Equals(other.OwnerId) ) && ( IsHired == other.IsHired || IsHired.Equals(other.IsHired) ) && ( SeniorityString == other.SeniorityString || SeniorityString != null && SeniorityString.Equals(other.SeniorityString) ) && ( Make == other.Make || Make != null && Make.Equals(other.Make) ) && ( Model == other.Model || Model != null && Model.Equals(other.Model) ) && ( Size == other.Size || Size != null && Size.Equals(other.Size) ) && ( EquipmentCode == other.EquipmentCode || EquipmentCode != null && EquipmentCode.Equals(other.EquipmentCode) ) && ( AttachmentCount == other.AttachmentCount || AttachmentCount.Equals(other.AttachmentCount) ) && ( LastVerifiedDate == other.LastVerifiedDate || LastVerifiedDate != null && LastVerifiedDate.Equals(other.LastVerifiedDate) ) && ( SenioritySortOrder == other.SenioritySortOrder || SenioritySortOrder.Equals(other.SenioritySortOrder) )); }
public bool IsEqual(object obj) { if (obj == null) { return(false); } if (object.ReferenceEquals(this, obj)) { return(true); } if (obj.GetType() != this.GetType()) { return(false); } DefaultListingPdfReportSetting setting = (DefaultListingPdfReportSetting)obj; if (string.IsNullOrEmpty(OwnerName)) { if (!string.IsNullOrEmpty(setting.OwnerName)) { return(false); } } else { if (!OwnerName.Equals(setting.OwnerName)) { return(false); } } if (IsEmployerVisible != setting.IsEmployerVisible) { return(false); } if (IsOwnerNameVisible != setting.IsOwnerNameVisible) { return(false); } if (AreShortHalfHoursEnabled != setting.AreShortHalfHoursEnabled) { return(false); } if (AreWorkedHoursVisible != setting.AreWorkedHoursVisible) { return(false); } if (AreLunchHoursVisible != setting.AreLunchHoursVisible) { return(false); } if (AreOtherHoursVisible != setting.AreOtherHoursVisible) { return(false); } if (AreTotalWorkedHoursVisible != setting.AreTotalWorkedHoursVisible) { return(false); } if (IsVacationVisible != setting.IsVacationVisible) { return(false); } if (AreSiknessHoursVisible != setting.AreSiknessHoursVisible) { return(false); } if (AreHolidaysHoursVisible != setting.AreHolidaysHoursVisible) { return(false); } if (IsHourlyWageVisible != setting.IsHourlyWageVisible) { return(false); } if (AreVacationDaysVisible != setting.AreVacationDaysVisible) { return(false); } if (AreDietsVisible != setting.AreDietsVisible) { return(false); } if (ArePaidHolidaysVisible != setting.ArePaidHolidaysVisible) { return(false); } if (AreBonusesVisible != setting.AreBonusesVisible) { return(false); } if (AreDollarsVisible != setting.AreDollarsVisible) { return(false); } if (IsPrepaymentVisible != setting.IsPrepaymentVisible) { return(false); } if (IsSicknessVisible != setting.IsSicknessVisible) { return(false); } return(true); }
/// <summary> /// Returns true if SeniorityViewModel instances are equal /// </summary> /// <param name="other">Instance of SeniorityViewModel to be compared</param> /// <returns>Boolean</returns> public bool Equals(SeniorityViewModel other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( EquipmentType == other.EquipmentType || EquipmentType != null && EquipmentType.Equals(other.EquipmentType) ) && ( OwnerName == other.OwnerName || OwnerName != null && OwnerName.Equals(other.OwnerName) ) && ( OwnerId == other.OwnerId || OwnerId != null && OwnerId.Equals(other.OwnerId) ) && ( SeniorityString == other.SeniorityString || SeniorityString != null && SeniorityString.Equals(other.SeniorityString) ) && ( Seniority == other.Seniority || Seniority != null && Seniority.Equals(other.Seniority) ) && ( Make == other.Make || Make != null && Make.Equals(other.Make) ) && ( Model == other.Model || Model != null && Model.Equals(other.Model) ) && ( Size == other.Size || Size != null && Size.Equals(other.Size) ) && ( EquipmentCode == other.EquipmentCode || EquipmentCode != null && EquipmentCode.Equals(other.EquipmentCode) ) && ( LastCalled == other.LastCalled || LastCalled != null && LastCalled.Equals(other.LastCalled) ) && ( YearsRegistered == other.YearsRegistered || YearsRegistered != null && YearsRegistered.Equals(other.YearsRegistered) ) && ( YtdHours == other.YtdHours || YtdHours != null && YtdHours.Equals(other.YtdHours) ) && ( HoursYearMinus1 == other.HoursYearMinus1 || HoursYearMinus1 != null && HoursYearMinus1.Equals(other.HoursYearMinus1) ) && ( HoursYearMinus2 == other.HoursYearMinus2 || HoursYearMinus2 != null && HoursYearMinus2.Equals(other.HoursYearMinus2) ) && ( HoursYearMinus3 == other.HoursYearMinus3 || HoursYearMinus3 != null && HoursYearMinus3.Equals(other.HoursYearMinus3) ) && ( SenioritySortOrder == other.SenioritySortOrder || SenioritySortOrder.Equals(other.SenioritySortOrder) )); }