private IOrderedEnumerable <TestDataElement> GetStandardSort(TestDataElement[] testArray, TestInfo testInfo) { IEnumerable <TestDataElement> sorted = testArray.Select(X => X); if (testInfo.Sort1Order == SortOrder.Ascending) { sorted = sorted.OrderBy(X => X.Property1); } else { sorted = sorted.OrderByDescending(X => X.Property1); } if (testInfo.SortLevel >= 2) { if (testInfo.Sort2Order == SortOrder.Ascending) { sorted = ((IOrderedEnumerable <TestDataElement>)sorted).ThenBy(X => X.Property2); } else { sorted = ((IOrderedEnumerable <TestDataElement>)sorted).ThenByDescending(X => X.Property2); } if (testInfo.SortLevel >= 3) { if (testInfo.Sort3Order == SortOrder.Ascending) { sorted = ((IOrderedEnumerable <TestDataElement>)sorted).ThenBy(X => X.Property3); } else { sorted = ((IOrderedEnumerable <TestDataElement>)sorted).ThenByDescending(X => X.Property3); } if (testInfo.SortLevel >= 4) { if (testInfo.Sort4Order == SortOrder.Ascending) { sorted = ((IOrderedEnumerable <TestDataElement>)sorted).ThenBy(X => X.Property4); } else { sorted = ((IOrderedEnumerable <TestDataElement>)sorted).ThenByDescending(X => X.Property4); } } } } return((IOrderedEnumerable <TestDataElement>)sorted); }
private IEnumerable <TestDataElement> PreSortTestData(IEnumerable <TestDataElement> testData, TestInfo testInfo) { TestInfo temp = testInfo; if (testInfo.SourceOrder == -1) { if (temp.Sort1Order == SortOrder.Ascending) { temp.Sort1Order = SortOrder.Descending; } else if (temp.Sort1Order == SortOrder.Descending) { temp.Sort1Order = SortOrder.Ascending; } if (temp.Sort2Order == SortOrder.Ascending) { temp.Sort2Order = SortOrder.Descending; } else if (temp.Sort2Order == SortOrder.Descending) { temp.Sort2Order = SortOrder.Ascending; } if (temp.Sort3Order == SortOrder.Ascending) { temp.Sort3Order = SortOrder.Descending; } else if (temp.Sort3Order == SortOrder.Descending) { temp.Sort3Order = SortOrder.Ascending; } if (temp.Sort4Order == SortOrder.Ascending) { temp.Sort4Order = SortOrder.Descending; } else if (temp.Sort4Order == SortOrder.Descending) { temp.Sort4Order = SortOrder.Ascending; } } return(GetStandardSort(testData.ToArray(), temp)); }
private IComposableSortEnumerable <TestDataElement> GetLinqLibSort(TestDataElement[] testArray, TestInfo testInfo) { IEnumerable <TestDataElement> sorted = testArray.Select(X => X); if (testInfo.Sort1Order == SortOrder.Ascending) { sorted = sorted.OrderBy(X => X.Property1, testInfo.Sort1Type); } else { sorted = sorted.OrderByDescending(X => X.Property1, testInfo.Sort1Type); } if (testInfo.SortLevel >= 2) { if (testInfo.Sort2Order == SortOrder.Ascending) { sorted = ((IComposableSortEnumerable <TestDataElement>)sorted).ThenBy(X => X.Property2, testInfo.Sort2Type); } else { sorted = ((IComposableSortEnumerable <TestDataElement>)sorted).ThenByDescending(X => X.Property2, testInfo.Sort2Type); } if (testInfo.SortLevel >= 3) { if (testInfo.Sort3Order == SortOrder.Ascending) { sorted = ((IComposableSortEnumerable <TestDataElement>)sorted).ThenBy(X => X.Property3, testInfo.Sort3Type); } else { sorted = ((IComposableSortEnumerable <TestDataElement>)sorted).ThenByDescending(X => X.Property3, testInfo.Sort3Type); } if (testInfo.SortLevel >= 4) { if (testInfo.Sort4Order == SortOrder.Ascending) { sorted = ((IComposableSortEnumerable <TestDataElement>)sorted).ThenBy(X => X.Property4, testInfo.Sort4Type); } else { sorted = ((IComposableSortEnumerable <TestDataElement>)sorted).ThenByDescending(X => X.Property4, testInfo.Sort4Type); } } } } return((IComposableSortEnumerable <TestDataElement>)sorted); }