protected override int Compare(DirectoryViewModel x, DirectoryViewModel y, SortingColumn sortingColumn) { if (x.IsParentDirectory) { return(-1); } if (y.IsParentDirectory) { return(1); } switch (sortingColumn) { case SortingColumn.Extension: case SortingColumn.Size: case SortingColumn.Name: return(string.Compare(PreprocessFileName(x.Name), PreprocessFileName(y.Name), StringComparison.Ordinal)); case SortingColumn.Date: return(x.LastModifiedDateTime.CompareTo(y.LastModifiedDateTime)); default: throw new ArgumentOutOfRangeException(nameof(SortingColumn)); } }
protected override int Compare(DirectoryViewModel x, DirectoryViewModel y, SortingColumn sortingColumn, bool isAscending) { if (x.IsParentDirectory) { return(-1); } if (y.IsParentDirectory) { return(1); } var sortingByNameColumns = new[] { SortingColumn.Extension, SortingColumn.Size, SortingColumn.Name }; var result = sortingColumn switch { _ when sortingByNameColumns.Contains(sortingColumn) => string.Compare(PreprocessFileName(x.Name), PreprocessFileName(y.Name), StringComparison.Ordinal), SortingColumn.Date => x.LastModifiedDateTime.CompareTo(y.LastModifiedDateTime), _ => throw new ArgumentOutOfRangeException(nameof(SortingColumn)) }; return(isAscending ? result : -result); } }
public override void Sort(DataGridViewColumn dataGridViewColumn, ListSortDirection direction) { SortingColumn?.Invoke(this, new SortingColumnEventArgs(dataGridViewColumn, direction)); base.Sort(dataGridViewColumn, direction); }
public void Test(SortingColumn sortingColumn, SortingColumn newSortingColumn, bool isSortingByAscendingEnabled) { var viewModel = new FileSystemNodesSortingViewModel(sortingColumn, isSortingByAscendingEnabled); Assert.Equal(sortingColumn, viewModel.SortingColumn); Assert.Equal(isSortingByAscendingEnabled, viewModel.IsSortingByAscendingEnabled); viewModel.SortingColumn = newSortingColumn; Assert.Equal(newSortingColumn, viewModel.SortingColumn); viewModel.ToggleSortingDirection(); Assert.Equal(!isSortingByAscendingEnabled, viewModel.IsSortingByAscendingEnabled); }
public void TestSortingParentDirectory(bool isAscending, SortingColumn sortingColumn) { var parentDirectoryViewModel = _autoMocker.CreateInstance <DirectoryViewModel>(); parentDirectoryViewModel.IsParentDirectory = true; var directoryViewModel = _autoMocker.CreateInstance <DirectoryViewModel>(); var comparer = new FileSystemNodesComparer(isAscending, sortingColumn); var result = comparer.Compare(parentDirectoryViewModel, directoryViewModel); Assert.True(result < 0); result = comparer.Compare(directoryViewModel, parentDirectoryViewModel); Assert.True(result > 0); }
protected override int Compare(FileViewModel x, FileViewModel y, SortingColumn sortingColumn, bool isAscending) { var result = sortingColumn switch { SortingColumn.Extension => string.Compare(x.Extension, y.Extension, StringComparison.InvariantCulture), SortingColumn.Size => x.Size.CompareTo(y.Size), SortingColumn.Name => string.Compare(PreprocessFileName(x.Name), PreprocessFileName(y.Name), StringComparison.Ordinal), SortingColumn.Date => x.LastModifiedDateTime.CompareTo(y.LastModifiedDateTime), _ => throw new ArgumentOutOfRangeException(nameof(SortingColumn)) }; return(isAscending ? result : -result); } }
public void TestCreate(SortingColumn sortingColumn, bool isSortingByAscendingEnabled) { var viewModelMock = new Mock <IFileSystemNodesSortingViewModel>(); viewModelMock .SetupGet(m => m.SortingColumn) .Returns(sortingColumn); viewModelMock .SetupGet(m => m.IsSortingByAscendingEnabled) .Returns(isSortingByAscendingEnabled); var factory = new FileSystemNodeViewModelComparerFactory(); var comparer = factory.Create(viewModelMock.Object); Assert.NotNull(comparer); Assert.IsType <FileSystemNodesComparer>(comparer); }
protected override int Compare(FileModel x, FileModel y, SortingColumn sortingColumn) { if (x is null) { throw new ArgumentNullException(nameof(x)); } if (y is null) { throw new ArgumentNullException(nameof(y)); } return(sortingColumn switch { SortingColumn.Extension => string.Compare(x.Extension, y.Extension, StringComparison.InvariantCulture), SortingColumn.Size => x.SizeBytes.CompareTo(y.SizeBytes), SortingColumn.Name => string.Compare(PreprocessFileName(x.Name), PreprocessFileName(y.Name), StringComparison.Ordinal), SortingColumn.Date => x.LastModifiedDateTime.CompareTo(y.LastModifiedDateTime), _ => throw new ArgumentOutOfRangeException(nameof(SortingColumn)) });
public FileSystemNodesComparer(bool isAscending, SortingColumn sortingColumn) { _directoriesComparer = new DirectoryViewModelsComparer(isAscending, sortingColumn); _filesComparer = new FileViewModelsComparer(isAscending, sortingColumn); }
public DirectoryViewModelsComparer(bool isAscending, SortingColumn sortingColumn) : base(isAscending, sortingColumn) { }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (SearchString != null) { hashCode = hashCode * 59 + SearchString.GetHashCode(); } if (SortingColumn != null) { hashCode = hashCode * 59 + SortingColumn.GetHashCode(); } if (TagId != null) { hashCode = hashCode * 59 + TagId.GetHashCode(); } if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (AssetNumber != null) { hashCode = hashCode * 59 + AssetNumber.GetHashCode(); } if (Latitude != null) { hashCode = hashCode * 59 + Latitude.GetHashCode(); } if (Longitude != null) { hashCode = hashCode * 59 + Longitude.GetHashCode(); } if (AssetClass != null) { hashCode = hashCode * 59 + AssetClass.GetHashCode(); } if (LastModified != null) { hashCode = hashCode * 59 + LastModified.GetHashCode(); } if (Created != null) { hashCode = hashCode * 59 + Created.GetHashCode(); } if (Creator != null) { hashCode = hashCode * 59 + Creator.GetHashCode(); } if (SubNumber != null) { hashCode = hashCode * 59 + SubNumber.GetHashCode(); } if (CompanyCode != null) { hashCode = hashCode * 59 + CompanyCode.GetHashCode(); } if (InventoryNumber != null) { hashCode = hashCode * 59 + InventoryNumber.GetHashCode(); } if (SerialNumber != null) { hashCode = hashCode * 59 + SerialNumber.GetHashCode(); } if (Location != null) { hashCode = hashCode * 59 + Location.GetHashCode(); } if (Room != null) { hashCode = hashCode * 59 + Room.GetHashCode(); } if (CostCenter != null) { hashCode = hashCode * 59 + CostCenter.GetHashCode(); } if (CapitalisationDate != null) { hashCode = hashCode * 59 + CapitalisationDate.GetHashCode(); } if (LastInventoryDate != null) { hashCode = hashCode * 59 + LastInventoryDate.GetHashCode(); } if (AcquisitionValue != null) { hashCode = hashCode * 59 + AcquisitionValue.GetHashCode(); } if (AssetSuperNumber != null) { hashCode = hashCode * 59 + AssetSuperNumber.GetHashCode(); } if (Vendor != null) { hashCode = hashCode * 59 + Vendor.GetHashCode(); } if (TypeName != null) { hashCode = hashCode * 59 + TypeName.GetHashCode(); } if (Plant != null) { hashCode = hashCode * 59 + Plant.GetHashCode(); } if (Quantity != null) { hashCode = hashCode * 59 + Quantity.GetHashCode(); } if (Unit != null) { hashCode = hashCode * 59 + Unit.GetHashCode(); } if (Untaggable != null) { hashCode = hashCode * 59 + Untaggable.GetHashCode(); } if (Untagged != null) { hashCode = hashCode * 59 + Untagged.GetHashCode(); } if (Page != null) { hashCode = hashCode * 59 + Page.GetHashCode(); } if (PageSize != null) { hashCode = hashCode * 59 + PageSize.GetHashCode(); } return(hashCode); } }
/// <summary> /// Returns true if AssetFullTextAndPropertySearch instances are equal /// </summary> /// <param name="other">Instance of AssetFullTextAndPropertySearch to be compared</param> /// <returns>Boolean</returns> public bool Equals(AssetFullTextAndPropertySearch other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( SearchString == other.SearchString || SearchString != null && SearchString.Equals(other.SearchString) ) && ( SortingColumn == other.SortingColumn || SortingColumn != null && SortingColumn.Equals(other.SortingColumn) ) && ( TagId == other.TagId || TagId != null && TagId.Equals(other.TagId) ) && ( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( AssetNumber == other.AssetNumber || AssetNumber != null && AssetNumber.Equals(other.AssetNumber) ) && ( Latitude == other.Latitude || Latitude != null && Latitude.Equals(other.Latitude) ) && ( Longitude == other.Longitude || Longitude != null && Longitude.Equals(other.Longitude) ) && ( AssetClass == other.AssetClass || AssetClass != null && AssetClass.Equals(other.AssetClass) ) && ( LastModified == other.LastModified || LastModified != null && LastModified.Equals(other.LastModified) ) && ( Created == other.Created || Created != null && Created.Equals(other.Created) ) && ( Creator == other.Creator || Creator != null && Creator.Equals(other.Creator) ) && ( SubNumber == other.SubNumber || SubNumber != null && SubNumber.Equals(other.SubNumber) ) && ( CompanyCode == other.CompanyCode || CompanyCode != null && CompanyCode.Equals(other.CompanyCode) ) && ( InventoryNumber == other.InventoryNumber || InventoryNumber != null && InventoryNumber.Equals(other.InventoryNumber) ) && ( SerialNumber == other.SerialNumber || SerialNumber != null && SerialNumber.Equals(other.SerialNumber) ) && ( Location == other.Location || Location != null && Location.Equals(other.Location) ) && ( Room == other.Room || Room != null && Room.Equals(other.Room) ) && ( CostCenter == other.CostCenter || CostCenter != null && CostCenter.Equals(other.CostCenter) ) && ( CapitalisationDate == other.CapitalisationDate || CapitalisationDate != null && CapitalisationDate.Equals(other.CapitalisationDate) ) && ( LastInventoryDate == other.LastInventoryDate || LastInventoryDate != null && LastInventoryDate.Equals(other.LastInventoryDate) ) && ( AcquisitionValue == other.AcquisitionValue || AcquisitionValue != null && AcquisitionValue.Equals(other.AcquisitionValue) ) && ( AssetSuperNumber == other.AssetSuperNumber || AssetSuperNumber != null && AssetSuperNumber.Equals(other.AssetSuperNumber) ) && ( Vendor == other.Vendor || Vendor != null && Vendor.Equals(other.Vendor) ) && ( TypeName == other.TypeName || TypeName != null && TypeName.Equals(other.TypeName) ) && ( Plant == other.Plant || Plant != null && Plant.Equals(other.Plant) ) && ( Quantity == other.Quantity || Quantity != null && Quantity.Equals(other.Quantity) ) && ( Unit == other.Unit || Unit != null && Unit.Equals(other.Unit) ) && ( Untaggable == other.Untaggable || Untaggable != null && Untaggable.Equals(other.Untaggable) ) && ( Untagged == other.Untagged || Untagged != null && Untagged.Equals(other.Untagged) ) && ( Page == other.Page || Page != null && Page.Equals(other.Page) ) && ( PageSize == other.PageSize || PageSize != null && PageSize.Equals(other.PageSize) )); }
public SearchResult SearchToursWithPriceForMen(int cityKeyFrom, int countryKey, List <int> tourKeys, List <DateTime> tourDates, List <int> tourNights, List <int> hotelKeys, List <int> pansionKeys, List <int> roomTypeKeys, QuotesStates hotelQuotaMask, QuotesStates aviaQuotaMask, int rateKey, uint?maxTourPrice, ushort rowsPerPage, uint rowCounterFrom, SortingColumn sortingColumn, SortingDirection sortingDirection, FlightTicketState flightTicketState) { if (!IsCountryPriceForMen(countryKey)) { throw new ApplicationException( "Данная страна посчитана с ценами за номер. Используйте для поиска метод SearchToursWithRoomPrice."); } // ReSharper disable RedundantNameQualifier Seemplexity.Services.Wcf.ToursSearch.DataModel.SearchResult searchResult; // ReSharper restore RedundantNameQualifier using (var mtsDc = new MtSearchDbDataContext()) { using (var mtmDc = new MtMainDbDataContext()) { searchResult = // ReSharper disable RedundantNameQualifier new Seemplexity.Services.Wcf.ToursSearch.DataModel.SearchResult(mtsDc.PagingOnClient(mtmDc, // ReSharper restore RedundantNameQualifier cityKeyFrom, countryKey, tourKeys, tourDates, tourNights, hotelKeys, pansionKeys, null, null, null, null, roomTypeKeys, (QDSearch.DataModel.QuotesStates)hotelQuotaMask, (QDSearch.DataModel.QuotesStates)aviaQuotaMask, rateKey, maxTourPrice, rowsPerPage, rowCounterFrom, new Tuple <QDSearch.DataModel.SortingColumn, QDSearch.DataModel.SortingDirection>( (QDSearch.DataModel.SortingColumn)sortingColumn, (QDSearch.DataModel.SortingDirection)sortingDirection))); } } return(searchResult); }
public FileModelsFileSystemNodesComparer(bool isAscending, SortingColumn sortingColumn) : base(isAscending, sortingColumn) { }
protected override int Compare(FileViewModel x, FileViewModel y, SortingColumn sortingColumn) => sortingColumn switch {
protected abstract int Compare(T x, T y, SortingColumn sortingColumn);
protected FileSystemNodesComparerBase(bool isAscending, SortingColumn sortingColumn) { _isAscending = isAscending; _sortingColumn = sortingColumn; }
protected abstract int Compare(T x, T y, SortingColumn sortingColumn, bool isAscending);
public FileViewModelsComparer(bool isAscending, SortingColumn sortingColumn) : base(isAscending, sortingColumn) { }