public void Sort(String SortBy, SortOrderEnum SortOrder) { GenericComparer comparer = new GenericComparer(); comparer.SortOrder = SortOrder; comparer.SortProperty = SortBy; this.InnerList.Sort(comparer); }
/// <summary> /// Queries all structures contained in the Structures data table using a wildcard query. The '?' and '*' wildcard characters can be used to /// query the structures in the function. The '?' character will serve as a single character wildcard in the string, whereas the '*' character /// will serve as a wildcard for any number of characters proceeding the wildcard symbol. If the MatchCase parameter is set to true, then /// the wildcard query will be case-sensitive. /// </summary> /// <param name="strExpression"></param> /// <param name="blMatchCase"></param> /// <returns></returns> public CHeaderDataSet.tblStructuresRow[] QueryStructsByWildcard( string strExpression, bool blMatchCase = false, SortOrderEnum sortOrder = SortOrderEnum.Ascending, StructUnionEnum structOrUnion = StructUnionEnum.Both) { try { IEnumerable <CHeaderDataSet.tblStructuresRow> qryStructRows = null; CHeaderDataSet.tblStructuresRow[] aryStructRows = null; strExpression = "^" + strExpression.Replace('?', '.').Replace("*", "\\w*") + "\\z"; if (!blMatchCase) { strExpression = "(?i)" + strExpression; qryStructRows = StructuresTable.Where(s => Regex.IsMatch(s.StructName, strExpression)); } else { strExpression = "(?-i)" + strExpression; qryStructRows = StructuresTable.Where(s => Regex.IsMatch(s.StructName, strExpression)); }//end if if (structOrUnion != StructUnionEnum.Both) { if (structOrUnion == StructUnionEnum.Structure) { qryStructRows = qryStructRows.Where(s => s.StructUnion == 1); } else { qryStructRows = qryStructRows.Where(s => s.StructUnion == 2); } }//end if if (sortOrder == SortOrderEnum.Ascending) { qryStructRows = qryStructRows.OrderBy(s => s.StructName); } else { qryStructRows = qryStructRows.OrderByDescending(s => s.StructName); } aryStructRows = qryStructRows.ToArray(); return(aryStructRows); } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in QueryStructsByWildcard function of DataAccess class."); return(null); } }
private void Sort(SortOrderEnum sortOrder) { var control = FindParent <CodeViewUserControl>(this); control.CodeDocumentViewModel.SortOrder = sortOrder; control.CodeDocumentViewModel.CodeDocument = SortHelper.Sort(control.CodeDocumentViewModel); Settings.Default.SortOrder = sortOrder; Settings.Default.Save(); }
public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader) { System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader)); this.RegionName = binaryReader.ReadStringID(); this.fieldpad = binaryReader.ReadBytes(1); this.fieldpad0 = binaryReader.ReadBytes(1); this.ParentVariant = binaryReader.ReadShortBlockIndex1(); pointerQueue.Enqueue(binaryReader.ReadBlamPointer(32)); this.SortOrder = ((SortOrderEnum)(binaryReader.ReadInt16())); this.fieldpad1 = binaryReader.ReadBytes(2); return(pointerQueue); }
/// <summary> /// Sort by a property. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="sortDir">Direction of sorting.</param> /// <returns>Current instance</returns> public IQueryConstraints <T> SortBy(string propertyName, SortOrderEnum sortDir) { if (string.IsNullOrEmpty(propertyName)) { return(this); } ValidatePropertyName(propertyName); sortOrder.Add(new SortOrderEntry(sortDir, propertyName)); return(this); }
public FilteredCountries GetCountries(int first, int rows, string sortField, SortOrderEnum sortOrder, Dictionary <string, string> filters) { var countryList = _context.Countries.ToList(); if (filters != null) { string value = string.Empty; if (filters.ContainsKey("Capital")) { filters.TryGetValue("Capital", out value); countryList = countryList.Where(n => n.Capital.Contains(value)).ToList(); } if (filters.ContainsKey("Name")) { filters.TryGetValue("Name", out value); countryList = countryList.Where(n => n.Name.Contains(value)).ToList(); } if (filters.ContainsKey("Region")) { filters.TryGetValue("Region", out value); countryList = countryList.Where(n => n.Region.Contains(value)).ToList(); } } var totalRows = countryList.Count(); switch (sortField) { case "Capital": countryList = sortOrder == SortOrderEnum.ASC ? countryList.OrderBy(n => n.Capital).Skip(first).Take(rows).ToList() : countryList.OrderByDescending(n => n.Capital).Skip(first).Take(rows).ToList(); break; case "Name": countryList = sortOrder == SortOrderEnum.ASC ? countryList.OrderBy(n => n.Name).Skip(first).Take(rows).ToList() : countryList.OrderByDescending(n => n.Name).Skip(first).Take(rows).ToList(); break; default: countryList = sortOrder == SortOrderEnum.ASC ? countryList.OrderBy(n => n.Id).Skip(first).Take(rows).ToList() : countryList.OrderByDescending(n => n.Id).Skip(first).Take(rows).ToList(); break; } var countries = new FilteredCountries() { Countries = countryList.ToList(), TotalCountries = totalRows }; return(countries); }
public static List <CodeItem> Sort(List <CodeItem> document, SortOrderEnum sortOrder) { switch (sortOrder) { case SortOrderEnum.SortByFile: return(SortByFile(document)); case SortOrderEnum.SortByName: return(SortByName(document)); default: return(document); } }
public void SortList() { SortOrderEnum sortOrder = SortOrder; List <BoundingRect> result = new List <BoundingRect>(); if (BrList == null) { return; } if (BrList.Count < 2) { return; } if (sortOrder == SortOrderEnum.UpperLeft) { var x = from b in BrList orderby b.OriginalUpperLeftY, b.OriginalUpperLeftX select b; result = x.ToList <BoundingRect>(); } if (sortOrder == SortOrderEnum.CentroidLocation) { var x = from b in BrList orderby b.CentroidX, b.CentroidY select b; result = x.ToList <BoundingRect>(); } if (sortOrder == SortOrderEnum.RelativeBrightness) { var x = from b in BrList orderby b.RelativeBrightness descending select b; result = x.ToList <BoundingRect>(); } if (sortOrder == SortOrderEnum.AbsoluteBrightness) { var x = from b in BrList orderby b.AbsoluteBrightness descending select b; result = x.ToList <BoundingRect>(); } if (sortOrder == SortOrderEnum.Volume) { var x = from b in BrList orderby b.Volume descending select b; result = x.ToList <BoundingRect>(); } BrList = result; }
static public string _GetSortMethodName(SortOrderEnum order) { switch (order) { case SortOrderEnum.Asc: return("OrderBy"); case SortOrderEnum.Desc: return("OrderByDescending"); default: throw new InvalidOperationException("Uknown sorting order = {0}".Form(order)); } }
/// <summary> /// Queries all structures from the Structure data table contained in the linked HeaderData data set that are within a specified range of data sizes. /// The structure rows will be queried and sorted in ascending or descending order. This function can be used to query either sets of structures or unions. /// </summary> /// <param name="iMinSize"></param> /// <param name="iMaxSize"></param> /// <param name="sortOrder"></param> /// <param name="structOrUnion"></param> /// <returns></returns> public CHeaderDataSet.tblStructuresRow[] QueryStructsBySize(int iMinSize, int iMaxSize = -1, SortOrderEnum sortOrder = SortOrderEnum.Ascending, StructUnionEnum structOrUnion = StructUnionEnum.Structure) { try { if (iMaxSize == -1) { iMaxSize = Int32.MaxValue; } IEnumerable <CHeaderDataSet.tblStructuresRow> qryStructRows = null; CHeaderDataSet.tblStructuresRow[] aryStructRows = null; qryStructRows = StructuresTable.Where(s => s.DataSize >= iMinSize && s.DataSize <= iMaxSize); if (structOrUnion != StructUnionEnum.Both) { if (structOrUnion == StructUnionEnum.Structure) { qryStructRows = qryStructRows.Where(s => s.StructUnion == 1); } else { qryStructRows = qryStructRows.Where(s => s.StructUnion == 2); } }//end if if (sortOrder == SortOrderEnum.Ascending) { qryStructRows = qryStructRows.OrderBy(s => s.DataSize); } else { qryStructRows = qryStructRows.OrderByDescending(s => s.DataSize); } aryStructRows = qryStructRows.ToArray(); return(aryStructRows); } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in QueryStructsBySize function of DataAccess class."); return(null); } }
public void ItemsSorting(SortOrderEnum sortOrder, string[] methodNames) { var document = SyntaxMapper.MapDocument(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\Files\\TestSorting.cs")); var viewModel = new CodeDocumentViewModel { CodeDocument = document, SortOrder = sortOrder }; viewModel.CodeDocument = SortHelper.Sort(viewModel); var sortingClass = (document.First() as IMembers).Members.First() as CodeClassItem; Assert.AreEqual(methodNames[0], sortingClass.Members.First().Name); Assert.AreEqual(methodNames[1], sortingClass.Members[1].Name); Assert.AreEqual(methodNames[2], sortingClass.Members.Last().Name); Assert.AreEqual(sortOrder, viewModel.SortOrder); }
/// <summary> /// Queries all structures contained in the Structures data table using a regular expression query. The results will match exactly to criteria /// specified in the regular expression and will be case and space sensitive. /// </summary> /// <param name="strRegex"></param> /// <returns></returns> public CHeaderDataSet.tblStructuresRow[] QueryStructsByRegex(string strRegex, SortOrderEnum sortOrder = SortOrderEnum.Ascending, StructUnionEnum structOrUnion = StructUnionEnum.Both) { try { IEnumerable <CHeaderDataSet.tblStructuresRow> qryStructRows = null; CHeaderDataSet.tblStructuresRow[] aryStructRows = null; qryStructRows = StructuresTable.Where(s => Regex.IsMatch(s.StructName, strRegex)); if (structOrUnion != StructUnionEnum.Both) { if (structOrUnion == StructUnionEnum.Structure) { qryStructRows = qryStructRows.Where(s => s.StructUnion == 1); } else { qryStructRows = qryStructRows.Where(s => s.StructUnion == 2); } }//end if if (sortOrder == SortOrderEnum.Ascending) { qryStructRows = qryStructRows.OrderBy(s => s.StructName); } else { qryStructRows = qryStructRows.OrderByDescending(s => s.StructName); } aryStructRows = qryStructRows.ToArray(); return(aryStructRows); } catch (Exception err) { ErrorHandler.ShowErrorMessage(err, "Error in QueryStructsByRegex function of DataAccess class."); return(null); } }
public WorkOrderButton(Guid id, List <string> workOrderAttribute, bool highlight, bool showCaption, int sortSequence, SortOrderEnum sortOrder, bool hideOnButton) { if (id == default(Guid)) { throw Error.Argument(string.Format("{0} can't be default guid.", nameof(id))); } if (workOrderAttribute == null) { throw Error.ArgumentNull(string.Format("{0} can't be empty.", nameof(workOrderAttribute))); } Id = id; WorkOrderAttribute = workOrderAttribute; Highlight = highlight; ShowCaption = showCaption; SortSequence = sortSequence; SortOrder = sortOrder; HideOnButton = hideOnButton; }
/// <summary> /// This is used to retrieve a page of product records. /// </summary> /// <returns></returns> public async Task <IEnumerable <ProductModel> > GetProductsWithPagingAsync(int firstRecordNumber, int pageSize, string sortField, SortOrderEnum sortOrder) { var response = await this._connectionFactory.GetConnection(async c => { IEnumerable <ProductModel> productModels = null; var p = new DynamicParameters(); p.Add("FirstRecordNumber", firstRecordNumber, DbType.Int32); p.Add("PageSize", pageSize, DbType.Int32); p.Add("SortField", sortField, DbType.String); p.Add("SortOrder", (int)sortOrder, DbType.Int32); productModels = await c.QueryAsync <ProductModel>(sql: "[CISPlus].[USP_CISBIS_ProdComp_GetALLProductsWithPaging]", param: p, commandType: CommandType.StoredProcedure); return(productModels); }); return(response); }
/// <summary> /// Initializes a new instance of the <see cref="OrderBySpec" /> class. /// </summary> /// <param name="key">The key that uniquely identifies a queryable address in Lusid. (required).</param> /// <param name="sortOrder">The available values are: Ascending, Descending (required).</param> public OrderBySpec(string key = default(string), SortOrderEnum sortOrder = default(SortOrderEnum)) { // to ensure "key" is required (not null) if (key == null) { throw new InvalidDataException("key is a required property for OrderBySpec and cannot be null"); } else { this.Key = key; } // to ensure "sortOrder" is required (not null) if (sortOrder == null) { throw new InvalidDataException("sortOrder is a required property for OrderBySpec and cannot be null"); } else { this.SortOrder = sortOrder; } }
/// <summary> /// This is used to retrieve a page of product records. /// </summary> /// <returns></returns> public async Task <IEnumerable <ProductModel> > GetProductsWithPagingAsync(int firstRecordNumber, int pageSize, string sortField, SortOrderEnum sortOrder) { if (true == string.IsNullOrEmpty(sortField) || true == string.Equals(sortField, "undefined", StringComparison.OrdinalIgnoreCase)) { sortField = "description"; } if (SortOrderEnum.Asc != sortOrder && SortOrderEnum.Desc != sortOrder) { sortOrder = SortOrderEnum.Asc; } var response = await this._productRepository .GetProductsWithPagingAsync(firstRecordNumber, pageSize, sortField, sortOrder); return(response); }
private void AlternatingSortByField(List <HRMISModel.Employee> employees, HRMISModel.Employee.EmployeeSortField employeeSortField, int columnNum, string columnTitle, SortOrderEnum defaultSortOrder) { SortOrderEnum sortOrder; if (ViewState[employeeSortField.ToString()] != null) { sortOrder = ViewState[employeeSortField.ToString()].ToString() == SortOrderEnum.Descending.ToString() ? SortOrderEnum.Ascending : SortOrderEnum.Descending; } else { sortOrder = defaultSortOrder.ToString() == SortOrderEnum.Descending.ToString() ? SortOrderEnum.Descending : SortOrderEnum.Ascending; } if (sortOrder == SortOrderEnum.Descending) { //倒序 gvMonthAttendanceList.Columns[columnNum].HeaderText = columnTitle + "<img src='../../image/down.gif' border='0'/>"; ViewState[employeeSortField.ToString()] = SortOrderEnum.Descending.ToString(); SortBase.InsertionSort(employees, new EmployeeComparer(employeeSortField, SortOrderEnum.Descending).Compare); } else { //正序 gvMonthAttendanceList.Columns[columnNum].HeaderText = columnTitle + "<img src='../../image/up.gif' border='0'/>"; ViewState[employeeSortField.ToString()] = SortOrderEnum.Ascending.ToString(); SortBase.InsertionSort(employees, new EmployeeComparer(employeeSortField, SortOrderEnum.Ascending).Compare); } }
private void Initialize() { this.fldHorizontallAlignment = StringAlignment.Center; this.fldVerticalAlignment = StringAlignment.Center; this.fldFormat = String.Empty; this._sortOrder = SortOrderEnum.Unsorted; this._displayZeroValue = true; }
public OrderListRequest SortByCreatedAt(SortOrderEnum order) { _params.AddOpt("sort_by[" + order.ToString().ToLower() + "]", "created_at"); return(this); }
/// <summary> /// 员工排序构造函数 /// </summary> /// <param name="field"></param> /// <param name="order"></param> public EmployeeComparer(Employee.EmployeeSortField field, SortOrderEnum order) { Field = field; Order = order; }
private void Page_Load(object sender, System.EventArgs e) { string Language = "en-US"; if (Request.UserLanguages.Length != 0) { Language = Request.UserLanguages[0]; } CurrentUserCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Language); if (ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"] != null) { ConnectionString = ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"]; } else if (Application["ConnectionString"] != null) { ConnectionString = Application["ConnectionString"].ToString().Trim(); } if (!Page.IsPostBack) { // Any sort preferences? CurrentSortEnum sortColumn = CurrentSortEnum.SortBy_Cat_StrName; if (Request.Params["SortBy"] != String.Empty) { try { sortColumn = (CurrentSortEnum)Enum.Parse(typeof(CurrentSortEnum), "SortBy_" + Request.Params["SortBy"]); } catch { // Ignore the parameter and do nothing here } } SortOrderEnum sortOrder = SortOrderEnum.Ascending; if (Request.Params["SortOrder"] != String.Empty) { try { sortOrder = (SortOrderEnum)Enum.Parse(typeof(SortOrderEnum), Request.Params["SortOrder"]); } catch { // Ignore the parameter and do nothing here } } if (ViewState["WebFormList_tblCategory_CurrentSort"] == null) { ViewState.Add("WebFormList_tblCategory_CurrentSort", sortColumn); } else { ViewState["WebFormList_tblCategory_CurrentSort"] = sortColumn; } if (ViewState["sortOrder"] == null) { ViewState.Add("sortOrder", sortOrder); } else { ViewState["sortOrder"] = sortOrder; } } repeater_tblCategory_SelectDisplay.EnableViewState = true; RefreshList(); }
public BoundingRectList() { BrList = new List <BoundingRect>(); SortOrder = SortOrderEnum.UpperLeft; }
private void Page_Load(object sender, System.EventArgs e) { string Language = "en-US"; if (Request.UserLanguages.Length != 0) { Language = Request.UserLanguages[0]; } CurrentUserCulture = System.Globalization.CultureInfo.CreateSpecificCulture(Language); if (ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"] != null) { ConnectionString = ConfigurationSettings.AppSettings["OlymarsDemo ConnectionString"]; } else if (Application["ConnectionString"] != null) { ConnectionString = Application["ConnectionString"].ToString().Trim(); } if (!Page.IsPostBack) { // com_Pro_LngCategoryID System.Data.SqlTypes.SqlInt32 colPro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Null; if (Request.Params["Pro_LngCategoryID"] != String.Empty) { try { colPro_LngCategoryID = System.Data.SqlTypes.SqlInt32.Parse(Request.Params["Pro_LngCategoryID"]); } catch { // Ignore the parameter and do nothing here } } com_Pro_LngCategoryID.Initialize(ConnectionString); try { com_Pro_LngCategoryID.RefreshData(colPro_LngCategoryID); } catch (OlymarsDemo.DataClasses.CustomException customException) { if (customException.Parameter.SqlException != null) { throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebDropDownList_tblCategory' class. Exception message is: {0}", customException.Parameter.SqlException.Message), customException); } else if (customException.Parameter.OtherException != null) { throw new Exception(String.Format("An exception has been thrown in the underlying DataClass that is used by the 'WebDropDownList_tblCategory' class. Exception message is: {0}", customException.Parameter.OtherException.Message), customException); } else { throw; } } com_Pro_LngCategoryID.Items.Insert(0, "Show all"); // Any sort preferences? CurrentSortEnum sortColumn = CurrentSortEnum.SortBy_Pro_StrName; if (Request.Params["SortBy"] != String.Empty) { try { sortColumn = (CurrentSortEnum)Enum.Parse(typeof(CurrentSortEnum), "SortBy_" + Request.Params["SortBy"]); } catch { // Ignore the parameter and do nothing here } } SortOrderEnum sortOrder = SortOrderEnum.Ascending; if (Request.Params["SortOrder"] != String.Empty) { try { sortOrder = (SortOrderEnum)Enum.Parse(typeof(SortOrderEnum), Request.Params["SortOrder"]); } catch { // Ignore the parameter and do nothing here } } if (ViewState["WebFormList_tblProduct_CurrentSort"] == null) { ViewState.Add("WebFormList_tblProduct_CurrentSort", sortColumn); } else { ViewState["WebFormList_tblProduct_CurrentSort"] = sortColumn; } if (ViewState["sortOrder"] == null) { ViewState.Add("sortOrder", sortOrder); } else { ViewState["sortOrder"] = sortOrder; } } repeater_tblProduct_SelectDisplay.EnableViewState = true; RefreshList(); }
/// <summary> /// Reset this column to its default values. /// </summary> public void Reset() { this._sortOrder = SortOrderEnum.Ascending; }
/// <summary> /// Initializes a new instance of the <see cref="OrderBySpec" /> class. /// </summary> /// <param name="key">The key that uniquely identifies a queryable address in Lusid. (required).</param> /// <param name="sortOrder">The available values are: Ascending, Descending (required).</param> public OrderBySpec(string key = default(string), SortOrderEnum sortOrder = default(SortOrderEnum)) { // to ensure "key" is required (not null) this.Key = key ?? throw new ArgumentNullException("key is a required property for OrderBySpec and cannot be null"); this.SortOrder = sortOrder; }
/// <summary> /// Initializes new instance of <see cref="SortOrderEntry"/>. /// </summary> /// <param name="sortOrder">kind of sort order.</param> /// <param name="sortPropertyName">property to sort by.</param> public SortOrderEntry(SortOrderEnum sortOrder, string sortPropertyName) { this.SortOrder = sortOrder; this.SortPropertyName = sortPropertyName; }
public TransactionListRequest SortByDate(SortOrderEnum order) { _params.AddOpt("sort_by[" + order.ToString().ToLower() + "]", "date"); return(this); }
public CreditNoteListRequest SortByDate(SortOrderEnum order) { m_params.AddOpt("sort_by[" + order.ToString().ToLower() + "]", "date"); return(this); }
/// <summary> /// Toggle the sort order of this column between ascending and descending. /// </summary> /// <returns>The new sort order for this column</returns> public SortOrderEnum SwitchSortOrder() { this._sortOrder = (this._sortOrder == SortOrderEnum.Ascending) ? SortOrderEnum.Descending : SortOrderEnum.Ascending; return this._sortOrder; }
public TransactionListRequest SortByUpdatedAt(SortOrderEnum order) { m_params.AddOpt("sort_by[" + order.ToString().ToLower() + "]", "updated_at"); return(this); }
public ItemListRequest SortById(SortOrderEnum order) { m_params.AddOpt("sort_by[" + order.ToString().ToLower() + "]", "id"); return(this); }
public EventListRequest SortByOccurredAt(SortOrderEnum order) { _params.AddOpt("sort_by[" + order.ToString().ToLower() + "]", "occurred_at"); return(this); }
public ActiveGridItemComparer() { this._col = 0; this._sortOrder = SortOrderEnum.Ascending; }
public UsageListRequest SortByUsageDate(SortOrderEnum order) { m_params.AddOpt("sort_by[" + order.ToString().ToLower() + "]", "usage_date"); return(this); }
public ActiveGridItemComparer(ActiveColumnHeader columnHeader) { this._columnHeader = columnHeader; this._sortOrder = columnHeader.SortOrder; this._col = columnHeader.Index; }