/// <summary> /// Get a list of type object by criterion expression /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sortOrder">Sort Order: Ascending or Descending</param> /// <param name="sortPropertie">Name of sort properties</param> /// <param name="criterions">A list of criterion expressions</param> /// <returns></returns> public static IList GetList(Type type, SortOrderType sortOrder, string sortProperty, ArrayList criterions) { ICriteria criteria = Session.CreateCriteria(type); if (criterions != null) { foreach (ICriterion expr in criterions) { criteria.Add(expr); } } if (!string.IsNullOrEmpty(sortProperty)) { if (SortOrderType.Ascending == sortOrder) { criteria.AddOrder(Order.Asc(sortProperty)); } else { criteria.AddOrder(Order.Desc(sortProperty)); } } return(criteria.List()); }
/// <summary> /// Get a list of T by criterion expression /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sortPropertie">Name of sort properties</param> /// <param name="sortOrder">Sort Order: Asc or Desc</param> /// <param name="criterions">A list of criterion expressions</param> /// <returns></returns> public static IList <T> GetList <T>(SortOrderType sortOrder, string sortPropertyName, params ICriterion[] criterions) { ICriteria criteria = Session.CreateCriteria(typeof(T)); if (criterions != null) { foreach (ICriterion expr in criterions) { criteria.Add(expr); } } if (!string.IsNullOrEmpty(sortPropertyName)) { if (SortOrderType.Ascending == sortOrder) { criteria.AddOrder(Order.Asc(sortPropertyName)); } else { criteria.AddOrder(Order.Desc(sortPropertyName)); } } return(criteria.List <T>()); }
/// <summary> /// Initializes a new instance of the <see cref="SortedField"/> class. /// </summary> /// <param name="propertyName">Name of the property.</param> /// <param name="sortOrder">The sort order.</param> /// <param name="sortOrderIndex">Index of the sort order.</param> /// <param name="isGroupBy">Indicates a grouped field if set to true </param> public SortedField(string propertyName, SortOrderType sortOrder, int sortOrderIndex, bool isGroupBy) { PropertyName = propertyName; SortOrder = sortOrder; SortOrderIndex = sortOrderIndex; IsGroupBy = isGroupBy; }
/// <summary> /// Constructor to use if you want to provide number of slots per node and your comparer object /// </summary> /// <param name="slotLen">Number of slots per node</param> /// <param name="comparer">compare object defining how records will be sorted</param> /// <param name="sortOrder"> </param> public ConcurrentSortedDictionary(byte slotLen = BTreeAlgorithm <TKey, TValue> .DefaultSlotLength, IComparer <TKey> comparer = null, SortOrderType sortOrder = SortOrderType.Ascending) { _btree = new BTreeAlgorithm <TKey, TValue>(slotLen, comparer); _currentItem = new BTreeAlgorithm <TKey, TValue> .TreeNode.ItemAddress(); _sortOrder = sortOrder; }
/// <summary> /// Returns a query which applies all of the common filters and enables paging. /// </summary> /// <returns></returns> public static Query DefaultQuery(int pageIndex, int pageSize, SortOrderType sot) { Query q = DefaultQuery(sot); q.PageIndex = pageIndex; q.PageSize = pageSize; return(q); }
/// <summary> /// Creates a new sort structure /// </summary> public ModelSort(Expression <Func <TData, dynamic> > property, SortOrderType order) { if (property.NodeType != ExpressionType.Lambda) { throw new ArgumentException($"{nameof(property)} must be a LambdaExpression"); } this.SortProperty = property; this.SortOrder = order; }
public int[] Sort(int[] input, int range, SortOrderType orderType) { if (input == null) { throw new InvalidOperationException("Array is null."); } else { return(RS(input, range, SortOrderType.Asc)); } }
public int[] Sort(int[] input, SortOrderType orderType) { if (input == null) { throw new InvalidOperationException("Array is null."); } else { int len = input.Length - 1; return(QS(input, 0, len, orderType)); } }
public override void SetMenuData(object param) { sortOrderLimit = SortOrderType.Activity; if (param != null) { currentTitle = param as LTActivityTitleItem; if (currentTitle == null) { sortOrderLimit = (SortOrderType)param; } } }
private int[] QS(int[] input, int low, int high, SortOrderType orderType) { if (low < high) { int pivot = Partition(input, low, high, orderType); QS(input, low, pivot - 1, orderType); QS(input, pivot + 1, high, orderType); } return(input); }
public IList <object> Sort(string key, int?offset, int?count, string BYpattern, string GETpattern, bool ALPHA, string STOREdestination, SortOrderType orderby, Type type, DataType dtype) { List <object> result = new List <object>(); using (RedisHost.ClientItem c = GetReader()) { using (Command cmd = new Command()) { cmd.Add(CONST_VALURES.REDIS_COMMAND_SORT); cmd.Add(key); if (!string.IsNullOrEmpty(BYpattern)) { cmd.Add("BY"); cmd.Add(BYpattern); } if (!string.IsNullOrEmpty(GETpattern)) { cmd.Add("GET"); cmd.Add(GETpattern); } if (offset != null) { cmd.Add("LIMIT"); cmd.Add(offset.Value.ToString()); cmd.Add(count == null?"1000":count.Value.ToString()); } if (ALPHA) { cmd.Add("ALPHA"); } cmd.Add(Enum.GetName(typeof(SortOrderType), orderby)); if (!string.IsNullOrEmpty(STOREdestination)) { cmd.Add("STORE"); cmd.Add(STOREdestination); } using (Result rd = TcpClient.Send(cmd, c.Client)) { foreach (ArraySegment <byte> item in rd.ResultDataBlock) { result.Add(FromRedis(item, dtype, type)); } } } } return(result); }
private void DrawInspector() { if (m_gameModule == null) { return; } GUILayout.BeginHorizontal(); if (GUILayout.Button("Show")) { m_gameModule.SetLayers(); } type = (SortOrderType)EditorGUILayout.EnumPopup(type, GUILayout.Width(60)); if (GUILayout.Button("Add")) { if (m_gameModule.m_canvasList == null) { m_gameModule.m_canvasList = new List <CanvasData>(); } CanvasData cd = new CanvasData(); cd.type = type; m_gameModule.m_canvasList.Add(cd); } GUILayout.EndHorizontal(); if (m_gameModule.m_canvasList == null || m_gameModule.m_canvasList.Count == 0) { return; } for (int i = 0; i < m_gameModule.m_canvasList.Count; i++) { GUILayout.BeginHorizontal(); switch (m_gameModule.m_canvasList[i].type) { case SortOrderType.canvas: ShowCanvasInspect(i); break; case SortOrderType.renderer: ShowParticleInspect(i); break; } if (GUILayout.Button("-", GUILayout.Width(30))) { m_gameModule.m_canvasList.RemoveAt(i); } GUILayout.EndHorizontal(); } }
static int QPYX_get_type_YXQP(IntPtr L_YXQP) { object QPYX_o_YXQP = null; try { QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1); CanvasData QPYX_obj_YXQP = (CanvasData)QPYX_o_YXQP; SortOrderType QPYX_ret_YXQP = QPYX_obj_YXQP.type; ToLua.Push(L_YXQP, QPYX_ret_YXQP); return(1); } catch (Exception QPYX_e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index type on a nil value")); } }
static int QPYX_set_type_YXQP(IntPtr L_YXQP) { object QPYX_o_YXQP = null; try { QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1); CanvasData QPYX_obj_YXQP = (CanvasData)QPYX_o_YXQP; SortOrderType QPYX_arg0_YXQP = (SortOrderType)ToLua.CheckObject(L_YXQP, 2, typeof(SortOrderType)); QPYX_obj_YXQP.type = QPYX_arg0_YXQP; return(0); } catch (Exception QPYX_e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index type on a nil value")); } }
/// <summary> /// Create sort expression. /// </summary> /// <param name="me">Me.</param> /// <param name="orderByProperty">The order by property.</param> /// <param name="sortOrder">The sort order.</param> /// <returns>Expression.</returns> public static Expression Sort(this Expression me, String orderByProperty, SortOrderType sortOrder) { // Get sort property var sortProperty = me.Type.GenericTypeArguments[0].GetRuntimeProperty(orderByProperty); Type predicateType = typeof(Func <,>).MakeGenericType(me.Type.GetTypeInfo().GenericTypeArguments[0], sortProperty.PropertyType); var sortMethod = typeof(Enumerable).GetGenericMethod(sortOrder.ToString(), new Type[] { me.Type.GetTypeInfo().GenericTypeArguments[0], sortProperty.PropertyType }, new Type[] { me.Type, predicateType }); // Get builder methods var sortParameter = Expression.Parameter(me.Type.GetTypeInfo().GenericTypeArguments[0], "sort"); var builderMethod = typeof(Expression).GetGenericMethod(nameof(Expression.Lambda), new Type[] { predicateType }, new Type[] { typeof(Expression), typeof(ParameterExpression[]) }); var sortLambda = builderMethod.Invoke(null, new object[] { Expression.MakeMemberAccess(sortParameter, sortProperty), new ParameterExpression[] { sortParameter } }) as Expression; return(Expression.Call(sortMethod as MethodInfo, me, sortLambda)); }
public int[] Sort(int[] input, int range, SortOrderType orderType) { if (input == null) { throw new InvalidOperationException("Array is null."); } else { int[] output = new int[input.Length]; int[] rangeArr = new int[range]; for (int i = 0; i < input.Length; i++) { rangeArr[input[i]] += 1; } for (int j = 1; j < range; j++) { rangeArr[j] += rangeArr[j - 1]; } for (int k = 0; k < input.Length; k++) { output[rangeArr[input[k]] - 1] = input[k]; rangeArr[input[k]] -= 1; } if (orderType == SortOrderType.Asc) { for (int x = 0; x < input.Length; x++) { input[x] = output[x]; } } else { int y = 0; for (int x = input.Length - 1; x >= 0; x--) { input[x] = output[y]; y += 1; } } } return(input); }
static int set_type(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); CanvasData obj = (CanvasData)o; SortOrderType arg0 = (SortOrderType)ToLua.CheckObject(L, 2, typeof(SortOrderType)); obj.type = arg0; return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index type on a nil value")); } }
static int get_type(IntPtr L) { object o = null; try { o = ToLua.ToObject(L, 1); CanvasData obj = (CanvasData)o; SortOrderType ret = obj.type; ToLua.Push(L, ret); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e, o, "attempt to index type on a nil value")); } }
private static string GetSortFilterUrlPart(SearchSortByType sortByType, SortOrderType orderByType) { var sorts = new Dictionary <SearchSortByType, string> { { SearchSortByType.Leechers, "leechers" }, { SearchSortByType.Seeders, "seeders" }, { SearchSortByType.Time, "time" }, { SearchSortByType.Size, "size" }, }; var orders = new Dictionary <SortOrderType, string> { { SortOrderType.Ascending, "asc" }, { SortOrderType.Descending, "desc" }, }; var sort = sorts[sortByType]; var order = orders[orderByType]; return($"{sort}/{order}"); }
/// <summary> /// Returns a query which applies all of the common filters /// </summary> /// <returns></returns> public static Query DefaultQuery(SortOrderType sot) { Query q = Post.CreateQuery(); q.AndWhere(Post.Columns.IsPublished, true); q.AndWhere(Post.Columns.IsDeleted, false); if (SiteSettings.Get().FilterUncategorizedPostsFromLists) { q.AndWhere(Post.Columns.CategoryId, CategoryController.UnCategorizedId, Comparison.NotEquals); } q.AndWhere(Post.Columns.Published, SiteSettings.CurrentUserTime, Comparison.LessOrEquals); switch (sot) { case SortOrderType.Ascending: q.OrderByAsc(Post.Columns.Published); break; case SortOrderType.Views: q.OrderByDesc(Post.Columns.Views); break; case SortOrderType.Custom: q.OrderByAsc(Post.Columns.SortOrder); break; case SortOrderType.Alphabetical: q.OrderByAsc(Post.Columns.Title); break; default: q.OrderByDesc(Post.Columns.Published); break; } return(q); }
/// <summary> /// The constructor of BatteryStatistics class. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="order">The criteria of the battery statistics sorted by.</param> /// <feature>http://tizen.org/feature/app_history</feature> /// <feature>http://tizen.org/feature/battery</feature> /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception> /// <exception cref="InvalidOperationException">Thrown when the method failed due to an internal error.</exception> /// <exception cref="NotSupportedException">Thrown when the features are not supported.</exception> public BatteryStatistics(SortOrderType order) { SortOrder = order; Uri = ConvertSortOrderToString((int)SortOrder); if (Uri == null) { throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.InvalidParameter, "Invalid SortOrderType"); } bool isSupported = false; int error = Interop.CtxHistory.IsSupported(Uri, out isSupported); if ((AppHistoryError)error != AppHistoryError.None) { throw AppHistoryErrorFactory.CheckAndThrowException((AppHistoryError)error, Uri); } if (!isSupported) { throw AppHistoryErrorFactory.CheckAndThrowException(AppHistoryError.NotSupported, Uri); } }
/// <summary> /// Get all T object /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sortOrder">Order type: Descending or Ascending</param> /// <param name="sortPropertyNames">A string array of properties will be sort</param> /// <returns></returns> public static IList <T> GetAll <T>(SortOrderType sortOrder, params string[] sortPropertyNames) { ICriteria criteria = Session.CreateCriteria(typeof(T)); if (sortPropertyNames != null) { if (SortOrderType.Ascending == sortOrder) { foreach (string propertyName in sortPropertyNames) { criteria.AddOrder(Order.Asc(propertyName)); } } else { foreach (string propertyName in sortPropertyNames) { criteria.AddOrder(Order.Desc(propertyName)); } } } return(criteria.List <T>()); }
private int Partition(int[] input, int low, int high, SortOrderType orderType) { int pivot = input[high]; int i = low; int temp = int.MinValue; for (int j = low; j < high; j++) { if (orderType == SortOrderType.Desc) { if (pivot <= input[j]) { temp = input[j]; input[j] = input[i]; input[i] = temp; i += 1; } } else { if (pivot >= input[j]) { temp = input[j]; input[j] = input[i]; input[i] = temp; i += 1; } } } temp = input[high]; input[high] = input[i]; input[i] = temp; return(i); }
public new IEnumerable <Category> GetAll(int take, ref int pageNumber, string columnOrder, SortOrderType orderType, out int count) { throw new NotImplementedException(); }
/// <summary> /// Returns a query which applies all of the common filters /// </summary> /// <returns></returns> public static Query DefaultQuery(SortOrderType sot) { Query q = Post.CreateQuery(); q.AndWhere(Post.Columns.IsPublished, true); q.AndWhere(Post.Columns.IsDeleted, false); if(SiteSettings.Get().FilterUncategorizedPostsFromLists) q.AndWhere(Post.Columns.CategoryId, CategoryController.UnCategorizedId, Comparison.NotEquals); q.AndWhere(Post.Columns.Published, SiteSettings.CurrentUserTime, Comparison.LessOrEquals); switch(sot) { case SortOrderType.Ascending: q.OrderByAsc(Post.Columns.Published); break; case SortOrderType.Views: q.OrderByDesc(Post.Columns.Views); break; case SortOrderType.Custom: q.OrderByAsc(Post.Columns.SortOrder); break; case SortOrderType.Alphabetical: q.OrderByAsc(Post.Columns.Title); break; default: q.OrderByDesc(Post.Columns.Published); break; } return q; }
/// <summary> /// Adds a SortedField to the collection using the specified parameters. /// </summary> /// <param name="propertyName">The name of the property to sort by.</param> /// <param name="sortOrder">The direction to sort by.</param> /// <param name="sortOrderIndex">The order to sort by.</param> public void Add(string propertyName, SortOrderType sortOrder, int sortOrderIndex) { Add(new SortedField(propertyName, sortOrder, sortOrderIndex)); }
/// <summary> /// Get all T objects by object type /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pageIndex">Index of page need to get data. Start with: 1, 2, 3,....</param> /// <param name="pageSize">Max record return</param> /// <param name="totalRows">Total record in datasource</param> /// <param name="sortOrder">Sort Order: Ascending or Descending</param> /// <param name="sortPropertie">Name of sort properties</param> /// <returns></returns> public static IList GetAll(Type type, int pageIndex, int pageSize, out int totalRows, SortOrderType sortOrder, params string[] sortPropertyNames) { ICriteria criteria = Session.CreateCriteria(type); if (sortPropertyNames != null) { if (SortOrderType.Ascending == sortOrder) { foreach (string propertyName in sortPropertyNames) { criteria.AddOrder(Order.Asc(propertyName)); } } else { foreach (string propertyName in sortPropertyNames) { criteria.AddOrder(Order.Desc(propertyName)); } } } totalRows = criteria.List().Count; criteria.SetFirstResult((pageIndex - 1) * pageSize); criteria.SetMaxResults(pageSize); return(criteria.List()); }
/// <summary> /// Construct an order by /// </summary> public SqlStatement OrderBy <TExpression>(Expression <Func <TExpression, dynamic> > orderField, SortOrderType sortOperation = SortOrderType.OrderBy) { var orderMap = TableMapping.Get(typeof(TExpression)); var orderCol = orderMap.GetColumn(this.GetMember(orderField.Body)); return(this.Append($"ORDER BY {orderMap.TableName}.{orderCol.Name} ").Append(sortOperation == SortOrderType.OrderBy ? " ASC " : " DESC ")); }
protected void Page_Load(object sender, System.EventArgs e) { try { GDC = new GalleryContext(); if (Context.Request.IsAuthenticated == true && (_Owner == "Any" || _Owner.ToLower().Contains(Context.User.Identity.Name.ToLower()))) { AdminMode = true; Session["GalleryOwner"] = _Owner; GalleryFeatures.Visible = true; // GalleryAdvanced.Visible = true; CategoriesDeleteButton.OnClientClick = "return alert('Are you sure you want to delete the category?')"; } if (Request.QueryString["Page"] != null) _CurrentPage = int.Parse(Request.QueryString["Page"].ToString()); if (Request.QueryString["PageSize"] != null) _PageSize = int.Parse(Request.QueryString["PageSize"].ToString()); if (Request.QueryString["SortOrder"] != null) { if (Request.QueryString["SortOrder"] == "Oldest") _SortOrder = SortOrderType.AscendingDate; else _SortOrder = SortOrderType.DescendingDate; } RenderGalleryUploads(); if (_IncludeCategories == true) RenderCategories(); if (_IncludeSearch == true) GallerySearch.Visible = true; if (_IncludeSort == true) RenderSort(); if (_IncludePageSize == true) RenderPageSize(); if (!Page.IsPostBack) ViewState["CurrentPage"] = _CurrentPage; BindRepeater(); } catch (Exception ex) { Label1.Text = ex.ToString() + "\n" + ex.Message; } }
/// <summary> /// Adds a <see cref="T:CoreVelocity.DataAccess.SortedField"/> to the collection using the specified parameters. /// </summary> /// <typeparam name="T">The type of object to find the property on using the specified linq expression.</typeparam> /// <param name="propertyName">The name of the property to sort by.</param> /// <param name="sortOrder">The direction to sort by.</param> public void Add(string propertyName, SortOrderType sortOrder) { Add(new SortedField(propertyName, sortOrder)); }
/// <summary> /// Get a list of type object by criterion expression /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pageIndex">Index of page need to get data. Start with: 1, 2, 3,....</param> /// <param name="pageSize">Max record return</param> /// <param name="totalRows">Total record in datasource</param> /// <param name="sortOrder">Sort Order: Ascending or Descending</param> /// <param name="sortPropertie">Name of sort properties</param> /// <param name="criterions">A list of criterion expressions</param> /// <returns></returns> public static IList GetList(Type type, int pageIndex, int pageSize, out int totalRows, SortOrderType sortOrder, string sortProperty, params ICriterion[] criterions) { ICriteria criteria = Session.CreateCriteria(type); if (criterions != null) { foreach (ICriterion expr in criterions) { criteria.Add(expr); } } if (!string.IsNullOrEmpty(sortProperty)) { if (SortOrderType.Ascending == sortOrder) { criteria.AddOrder(Order.Asc(sortProperty)); } else { criteria.AddOrder(Order.Desc(sortProperty)); } } totalRows = criteria.List().Count; criteria.SetFirstResult((pageIndex - 1) * pageSize); criteria.SetMaxResults(pageSize); return(criteria.List()); }
/// <summary> /// Adds a SortedField to the collection using the specified parameters. /// </summary> /// <param name="propertyName">The name of the property to sort by.</param> /// <param name="sortOrder">The direction to sort by.</param> /// <param name="sortOrderIndex">The order to sort by.</param> /// <param name="isGroupBy">Value indicating whether the sorted field is a grouped field.</param> public void Add(string propertyName, SortOrderType sortOrder, int sortOrderIndex, bool isGroupBy) { Add(new SortedField(propertyName, sortOrder, sortOrderIndex, isGroupBy)); }
/// <summary> /// Returns a query which applies all of the common filters and enables paging. /// </summary> /// <returns></returns> public static Query DefaultQuery(int pageIndex, int pageSize, SortOrderType sot) { Query q = DefaultQuery(sot); q.PageIndex = pageIndex; q.PageSize = pageSize; return q; }