Esempio n. 1
0
 /// <summary>
 /// Construct the object.
 /// </summary>
 ///
 /// <param name="theIndexindex">The index of the sorted field.</param>
 /// <param name="t">The type of sort, the type of object.</param>
 /// <param name="theAscending">True, if this is an ascending sort.</param>
 public SortedField(int theIndexindex, SortType t,
     bool theAscending)
 {
     _index = theIndexindex;
     Ascending = theAscending;
     _sortType = t;
 }
Esempio n. 2
0
        public override void DrawArrow(Context cr, Gdk.Rectangle alloc, SortType type)
        {
            cr.LineWidth = 1;
            cr.Translate (0.5, 0.5);
            double x1 = alloc.X;
            double x3 = alloc.X + alloc.Width / 2.0;
            double x2 = x3 + (x3 - x1);
            double y1 = alloc.Y;
            double y2 = alloc.Bottom;

            if (type == SortType.Ascending) {
                cr.MoveTo (x1, y1);
                cr.LineTo (x2, y1);
                cr.LineTo (x3, y2);
                cr.LineTo (x1, y1);
            } else {
                cr.MoveTo (x3, y1);
                cr.LineTo (x2, y2);
                cr.LineTo (x1, y2);
                cr.LineTo (x3, y1);
            }

            cr.SetSourceColor (Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal));
            cr.FillPreserve ();
            cr.SetSourceColor (Colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal));
            cr.Stroke ();
            cr.Translate (-0.5, -0.5);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a field that holds <see cref="QueryTypeProperties{T}"/> for the module.
        /// </summary>
        protected FieldDeclarationSyntax CreatePropertiesField(
            Module module, string resultClassName, FieldDeclarationSyntax propsField, SortType? sortType)
        {
            var queryTypePropertiesType = SyntaxEx.GenericName("QueryTypeProperties", resultClassName);

            var propertiesInitializer = SyntaxEx.ObjectCreation(
                queryTypePropertiesType,
                SyntaxEx.Literal(module.Name),
                SyntaxEx.Literal(module.Prefix),
                module.QueryType == null
                    ? (ExpressionSyntax)SyntaxEx.NullLiteral()
                    : SyntaxEx.MemberAccess("QueryType", module.QueryType.ToString()),
                sortType == null
                    ? (ExpressionSyntax)SyntaxEx.NullLiteral()
                    : SyntaxEx.MemberAccess("SortType", sortType.ToString()),
                CreateTupleListExpression(GetBaseParameters(module)),
                propsField == null ? (ExpressionSyntax)SyntaxEx.NullLiteral() : (NamedNode)propsField,
                resultClassName == "object"
                    ? (ExpressionSyntax)SyntaxEx.LambdaExpression("_", SyntaxEx.NullLiteral())
                    : SyntaxEx.MemberAccess(resultClassName, "Parse"));

            return SyntaxEx.FieldDeclaration(
                new[] { SyntaxKind.PrivateKeyword, SyntaxKind.StaticKeyword, SyntaxKind.ReadOnlyKeyword },
                queryTypePropertiesType, ClassNameBase + "Properties", propertiesInitializer);
        }
Esempio n. 4
0
 public CChartParameter(string ip_chart_description, string ip_Order_col_name, string ip_Caption_col_name, string ip_Data_col_name, SortType ip_sort_type)
 {
     strCaptionColName = ip_Caption_col_name;
     strDataColName = ip_Data_col_name;
     strOrderColName = ip_Order_col_name;
     strCaptionOfChart = ip_chart_description;
     type = ip_sort_type;
 }
Esempio n. 5
0
 /// <summary>
 /// A simple class that holds a single sort criterion.
 /// </summary>
 /// <param name="property">The data class' property to sort on.</param>
 /// <param name="direction">The direction to sort based on the Property.</param>
 public SortOrder(string property, SortType direction)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property",
             "Property must be a valid property/field name from the data class.");
     }
     Property = property;
     Direction = direction;
 }
 public TwitchList<FollowedChannel> GetFollowedChannels(string user, PagingInfo pagingInfo = null, SortDirection sortDirection = SortDirection.desc, SortType sortType = SortType.created_at)
 {
     var request = GetRequest("users/{user}/follows/channels", Method.GET);
     request.AddUrlSegment("user", user);
     TwitchHelper.AddPaging(request, pagingInfo);
     request.AddParameter("direction", sortDirection);
     request.AddParameter("sortby", sortType);
     var response = restClient.Execute<TwitchList<FollowedChannel>>(request);
     return response.Data;
 }
 public static EnumDescription[] GetFieldTexts(Type enumType, SortType sortType)
 {
     if (!EnumDescription.hashtable_0.Contains(enumType.FullName))
     {
         FieldInfo[] fields = enumType.GetFields();
         ArrayList arrayList = new ArrayList();
         FieldInfo[] array = fields;
         for (int i = 0; i < array.Length; i++)
         {
             FieldInfo fieldInfo = array[i];
             object[] customAttributes = fieldInfo.GetCustomAttributes(typeof(EnumDescription), false);
             if (customAttributes.Length == 1)
             {
                 ((EnumDescription)customAttributes[0]).fieldInfo_0 = fieldInfo;
                 arrayList.Add(customAttributes[0]);
             }
         }
         EnumDescription.hashtable_0.Add(enumType.FullName, arrayList.ToArray(typeof(EnumDescription)));
     }
     EnumDescription[] array2 = (EnumDescription[])EnumDescription.hashtable_0[enumType.FullName];
     if (array2.Length <= 0)
     {
         int num = 0;
         while (num < array2.Length && sortType != SortType.Default)
         {
             for (int j = num; j < array2.Length; j++)
             {
                 bool flag = false;
                 switch (sortType)
                 {
                     case SortType.DisplayText:
                         if (string.CompareOrdinal(array2[num].EnumDisplayText, array2[j].EnumDisplayText) > 0)
                         {
                             flag = true;
                         }
                         break;
                     case SortType.Rank:
                         if (array2[num].EnumRank > array2[j].EnumRank)
                         {
                             flag = true;
                         }
                         break;
                 }
                 if (flag)
                 {
                     EnumDescription enumDescription = array2[num];
                     array2[num] = array2[j];
                     array2[j] = enumDescription;
                 }
             }
             num++;
         }
     }
     return array2;
 }
 protected QueryTypeProperties(
     string moduleName, string prefix, QueryType? queryType, SortType? sortType,
     IEnumerable<Tuple<string, string>> baseParameters, IDictionary<string, string[]> props)
 {
     ModuleName = moduleName;
     Prefix = prefix;
     QueryType = queryType;
     SortType = sortType;
     BaseParameters = baseParameters;
     m_props = props ?? new Dictionary<string, string[]>();
 }
Esempio n. 9
0
		private void CustomInitializeComponent()
		{
			var cfg = _provider.GetRequiredService<IRsdnForumService>().GetConfig();
			_sortBy =
				cfg.ShowFullForumNames
					? _sortByDesc
					: _sortByName;
			_sortType =
				cfg.ShowFullForumNames
					? SortType.ByDesc
					: SortType.ByName;
			InitListView(false);
		}
Esempio n. 10
0
        public void Sort(Range key1=null, SortOrder? order1=null, Range key2 = null, SortType? type = null, SortOrder? order2 = null, Range key3 = null, SortOrder? order3 = null, YesNoGuess? header = YesNoGuess.No)
        {
            //if (!(key1 is String) && !(key1 is Range) && key1 != null)
            //    throw new ArgumentException("Key1 must be a string (range named) or a range object");

            //if (!(key2 is String) && !(key2 is Range) && key2 != null)
            //    throw new ArgumentException("Key2 must be a string (range named) or a range object");

            //if (!(key3 is String) && !(key3 is Range) && key3 != null)
            //    throw new ArgumentException("Key3 must be a string (range named) or a range object");

            InternalObject.GetType().InvokeMember("Sort", System.Reflection.BindingFlags.InvokeMethod, null, InternalObject, ComArguments.Prepare(key1, order1, key2, order2, key3, order3, header));
        }
Esempio n. 11
0
 public FilterViewModel(int columnId, string columnName, SortType sortType, BindableCollection<FilterCriteriaViewModel> filterCriteria, VideoPlayerViewModel viewModel)
 {
     this.columnId = columnId;
     this.ColumnHeaderName = columnName;
     this.sortType = sortType;
     this.filterCriteria = filterCriteria;
     this.viewModel = viewModel;
     IsAscendingChecked = false;
     IsDescendingChecked = false;
     IsNoneChecked = true;
     ApplyButtonVisibility = "Visible";
     RemoveButtonVisibility = "Collapsed";
     CloseButtonVisibility = "Visible";
 }
Esempio n. 12
0
 /// <summary>
 /// Constructor for Search operation. Takes in the following parameters
 /// to define the search filters to be used when the operation is executed.
 /// </summary>
 /// <param name="searchString">The string which the task name must contain to match the search.</param>
 /// <param name="startTime">The start time by which the task must within to match the search.</param>
 /// <param name="endTime">The end time by which the task must within to match the search.</param>
 /// <param name="isSpecific">The specificty of the time ranges.</param>
 /// <param name="searchType">The type of search filter to use in addition to the other filters.</param>
 /// <param name="sortType">The type of sort to sort the diplay list by after the operation is executed.</param>
 /// <returns>Response containing the search results, the operation's success or failure, and the new sort type if any.</returns>
 public OperationSearch(
     string searchString,
     DateTime? startTime,
     DateTime? endTime,
     DateTimeSpecificity isSpecific,
     SearchType searchType,
     SortType sortType)
     : base(sortType)
 {
     this.searchString = searchString;
     this.startTime = startTime;
     this.endTime = endTime;
     this.isSpecific = isSpecific;
     this.searchType = searchType;
 }
Esempio n. 13
0
 /// <summary>
 /// Sorts the items in a ListView in detail view by one of the columns, remembering previous sorting.
 /// </summary>
 /// <param name="list">ListView being sorted.</param>
 /// <param name="sortColumnIndex">Column to sort by.</param>
 /// <param name="sort">How to sort the data in the column.</param>
 /// <param name="reverse">True if list should be sorted in reverse order.</param>
 /// <param name="indicatorColumnIndex">Column to show sort indicator on.</param>
 public static void DetailSort(this ListView list, int sortColumnIndex, SortType sort, bool reverse, int indicatorColumnIndex) {
   if(list.View != View.Details)
     throw new ArgumentException(Properties.Resources.DetailsViewRequiredMessage, "list");
   ListViewItemSorter sorter = list.ListViewItemSorter as ListViewItemSorter;
   if(sorter == null) {
     sorter = new ListViewItemSorter(sortColumnIndex, sort, reverse, indicatorColumnIndex);
     list.ListViewItemSorter = sorter;
   } else {
     if(sorter.IndicatorColumn != indicatorColumnIndex)
       HideSortIndicator(list, sorter.IndicatorColumn);
     sorter.SortBy(sortColumnIndex, sort, reverse, indicatorColumnIndex);
   }
   ShowSortIndicator(list, indicatorColumnIndex, reverse);
   list.Sort();
 }
Esempio n. 14
0
        public MainWindowViewModel(MainWindow window)
        {
            _window = window;
            _selectedTasks = new List<Task>();

            Log.LogLevel = User.Default.DebugLoggingOn ? LogLevel.Debug : LogLevel.Error;

            Log.Debug("Initializing Todotxt.net");

            SortType = (SortType)User.Default.CurrentSort;


            if (!string.IsNullOrEmpty(User.Default.FilePath))
            {
                LoadTasks(User.Default.FilePath);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// This is the constructor for the Schedule operation.
 /// This operation accepts a time range and tries to schedule a task
 /// for the specified time period within the time range at the earliest
 /// possible point on execution.</summary>
 /// <param name="taskName">The name of the task to schedule.</param>
 /// <param name="startDateTime">The start date/time which the task should be scheduled within.</param>
 /// <param name="endDateTime">The end date/time which the task should be scheduled within.</param>
 /// <param name="isSpecific">The specificity of the start and end date time ranges.</param>
 /// <param name="timeRangeAmount">The numerical value of the task length of the task to be scheduled.</param>
 /// <param name="timeRangeType">The type of time length the task uses: hour, day, week or month.</param>
 /// <param name="sortType">The type of sort to sort the diplay list by after the operation is executed.</param>
 /// <returns>Nothing.</returns>
 public OperationSchedule(
     string taskName,
     DateTime startDateTime,
     DateTime? endDateTime,
     DateTimeSpecificity isSpecific,
     int timeRangeAmount,
     TimeRangeType timeRangeType,
     SortType sortType)
     : base(sortType)
 {
     this.taskName = taskName;
     this.startDateTime = startDateTime;
     this.endDateTime = endDateTime;
     this.isSpecific = isSpecific;
     this.taskDurationAmount = timeRangeAmount;
     this.taskDurationType = timeRangeType;
 }
Esempio n. 16
0
 /// <summary>
 /// This is the constructor for the Modify operation.
 /// It will modify the task indicated by the index range to the new
 /// parameters specified by the given arguments. If an arguement
 /// is left empty or null, that parameter will remain unchanged.
 /// </summary>
 /// <param name="taskName">The name of the task to modified. Can be a substring of it.</param>
 /// <param name="indexRange">The display index of the task to be modified.</param>
 /// <param name="startTime">The new start date to set for the task.</param>
 /// <param name="endTime">The new end date to set for the task.</param>
 /// <param name="isSpecific">The new Specificity of the dates for the task.</param>
 /// <param name="isAll">If this boolean is true, the operation will be invalid.</param>
 /// <param name="searchType">The type of search to be carried out (in addition to the other filters) if required.</param>
 /// <param name="sortType">The type of sort to sort the diplay list by after the operation is executed.</param>
 /// <returns>Nothing.</returns>
 public OperationModify(string taskName, int[] indexRange, DateTime? startTime,
     DateTime? endTime, DateTimeSpecificity isSpecific, bool isAll, SearchType searchType, SortType sortType)
     : base(sortType)
 {
     if (indexRange == null) hasIndex = false;
     else
     {
         hasIndex = true;
         this.startIndex = indexRange[TokenIndexRange.START_INDEX] - 1;
         this.endIndex = indexRange[TokenIndexRange.END_INDEX] - 1;
     }
     if (taskName == null) this.taskName = "";
     else this.taskName = taskName;
     this.startTime = startTime;
     this.endTime = endTime;
     this.isSpecific = isSpecific;
     this.isAll = isAll;
     this.searchType = searchType;
 }
Esempio n. 17
0
        public static List<string> GetList(SortType type, int zone,int page,DateTime from,DateTime to)
        {
            Log.Info("正在获取排行 - 依据" + type.ToString().ToLower() + "/分区" + zone + "/分页" + page + "/时间" + from.ToString("yyyy-MM-dd") + "~" + to.ToString("yyyy-MM-dd"));
            string url = "http://www.bilibili.com/list/" + type.ToString() + "-" + zone + "-" + page + "-" + from.ToString("yyyy-MM-dd") + "~" + to.ToString("yyyy-MM-dd") + ".html";
            string html = BiliInterface.GetHtml(url);
            if (html == null) return null;
            int p = 0;
            List<string> r = new List<string>();
            while (html.IndexOf("o/av", p) > 0)
            {
                p = html.IndexOf("o/av", p);
                string s = html.Substring(p + 2, html.IndexOf("/", p + 2) - p - 2);
                if (!r.Contains(s))
                    r.Add(s);

                p += 3;
            }
            return r;
        }
Esempio n. 18
0
 private void SortItems(SortType sortType)
 {
     IOrderedEnumerable<ExplorerItem> sortedSource = null;
     if (sortType == SortType.Date)
         sortedSource = SortByDate(ExplorerItems);
     else if (sortType == SortType.Name)
         sortedSource = SortByName(ExplorerItems);
     else if (sortType == SortType.Size)
         sortedSource = SortBySize(ExplorerItems);
     else if (sortType == SortType.Type)
         sortedSource = SortByType(ExplorerItems);
     else if (sortType == SortType.None)
         return;
     if (sortedSource != null)
     {
         RerangeDataSource(sortedSource);
         _counterForLoadUnloadedItems = 0;
     }
 }
        /// <summary>
        /// Initializes a new instance of the FlightResponseSettings with the specified parameters
        /// </summary>
        /// <param name="sortType">The property to sort on</param>
        /// <param name="sortOrder">Sort direction</param>
        /// <param name="maxStops">Filter for maximum number of stops. Between 0 and 3</param>
        /// <param name="maxDuration">Filter for maximum duration in minutes</param>
        /// <param name="outboundDepartureTime">Filter for outbound departure time by time period of the day </param>
        /// <param name="outboundDepartureStartTime">Filter for start of range for outbound departure time</param>
        /// <param name="outboundDepartureEndTime">Filter for end of range for outbound departure time</param>
        /// <param name="inboundDepartureTime">Filter for inbound departure time by time period of the day </param>
        /// <param name="inboundDepartureStartTime">Filter for start of range for inbound departure time</param>
        /// <param name="inboundDepartureEndTime">Filter for end of range for inbound departure time</param>
        /// <param name="originAirports">Origin airports to filter on. List of airport codes</param>
        /// <param name="destinationAirports">Destination airports to filter on. List of airport codes</param>
        /// <param name="includeCarriers">Filter flights by the specified carriers. Must be Iata carrier codes</param>
        /// <param name="excludeCarriers">Filter flights by any but the specified carriers. Must be Iata carrier codes</param>
        /// <param name="carrierSchema">The code schema to use for carriers</param>
        /// <param name="locationSchema">The code schema used for locations</param>
        public FlightResponseSettings(
            SortType sortType = SortType.Price, SortOrder sortOrder = SortOrder.Ascending,
            int? maxStops = null, int? maxDuration = null,
            DayTimePeriod? outboundDepartureTime = null, LocalTime? outboundDepartureStartTime = null,
            LocalTime? outboundDepartureEndTime = null,
            DayTimePeriod? inboundDepartureTime = null, LocalTime? inboundDepartureStartTime = null,
            LocalTime? inboundDepartureEndTime = null,
            IEnumerable<string> originAirports = null, IEnumerable<string> destinationAirports = null,
            IEnumerable<string> includeCarriers = null, IEnumerable<string> excludeCarriers = null,
            CarrierSchema carrierSchema = CarrierSchema.Iata, LocationSchema locationSchema = LocationSchema.Iata)
        {
            if (maxStops.HasValue && (maxStops.Value < 0 || maxStops.Value > 3))
            {
                throw new ArgumentException("The filter for maximum number of stops must be between 0 and 3", nameof(maxStops));
            }

            if (maxDuration.HasValue && (maxDuration.Value < 0 || maxDuration.Value > 1800))
            {
                throw new ArgumentException("The filter for maximum duration must be between 0 and 1800", nameof(maxDuration));
            }

            MaxDuration = maxDuration;
            MaxStops = maxStops;

            SortOrder = sortOrder;
            SortType = sortType;

            CarrierSchema = carrierSchema;
            LocationSchema = locationSchema;

            OriginAirports = originAirports;
            DestinationAirports = destinationAirports;
            IncludeCarriers = includeCarriers;
            ExcludeCarriers = excludeCarriers;

            OutboundDepartureTime = outboundDepartureTime;
            OutboundDepartureStartTime = outboundDepartureStartTime;
            OutboundDepartureEndTime = outboundDepartureEndTime;

            InboundDepartureTime = inboundDepartureTime;
            InboundDepartureStartTime = inboundDepartureStartTime;
            InboundDepartureEndTime = inboundDepartureEndTime;
        }
Esempio n. 20
0
        public ResponseResult<OrderModel> Get(int page, int page_size, DateTime start_date, DateTime end_date, OrderState order_state, string optional_fields = "", SortType sortType = SortType.Ase, DateType dateType = DateType.Modify_Time)
        {
            IJdClient client = new DefaultJdClient("","","");
            //http://jos.jd.com/api/detail.htm?id=691 接口地址
            var response = client.Execute(new UnionOrderServiceQueryOrdersRequest());
            //判断 是否接受错误  可忽略
            if (response.IsError)
            {

            }
            //对结果进行解析 理论上是响应的结果
            var t = response.queryordersResult;
            //是一窜json格式  OrderModel需要 对响应结果解析并且转换
            var parse=JsonConvert.DeserializeObject<OrderModel>(t);

            return new ResponseResult<OrderModel> {
                Code = int.Parse(response.ErrCode),
                Result = parse
            };
            //throw new NotImplementedException();
        }
Esempio n. 21
0
        public static void BubbleSort(int[] items, SortType sortOrder)
        {
            int i;
            int j;
            int temp;

            if (items == null)
            {
                return;
            }

            for (i = items.Length - 1; i >= 0; i--)
            {
                for (j = 1; j <= i; j++)
                {
                    switch (sortOrder)
                    {
                        case SortType.Ascending:
                            if (items[j - 1] > items[j])
                            {
                                temp = items[j - 1];
                                items[j - 1] = items[j];
                                items[j] = temp;
                            }

                            break;

                        case SortType.Descending:
                            if (items[j - 1] < items[j])
                            {
                                temp = items[j - 1];
                                items[j - 1] = items[j];
                                items[j] = temp;
                            }

                            break;
                    }
                }
            }
        }
Esempio n. 22
0
    public static void LoadData()
    {
        string dataString = PlayerPrefs.GetString("Game_0");

        if(dataString == null || dataString == "")
        {
            LoadDefaults();
            return;
        }

        var rootDict = Json.Deserialize(dataString) as Dictionary<string,object>;

        if(rootDict == null)
        {
            LoadDefaults();
            return;
        }

        if(rootDict.ContainsKey("sortType"))
        {
            _sortType = SortType.GetByName(rootDict["sortType"].ToString());
        }

        List<object> playerDatas = rootDict["players"] as List<object>;

        for(int p = 0; p<playerDatas.Count; p++)
        {
            Dictionary<string,object> playerData = playerDatas[p] as Dictionary<string,object>;

            Player player = new Player();

            player.name = playerData["name"].ToString();
            player.color = PlayerColor.GetColor(playerData["color"].ToString());
            player.score = int.Parse(playerData["score"].ToString());

            _players.Add(player);
        }
    }
Esempio n. 23
0
        public void OnColumnClick(object sender, EventArgs args)
        {
            TreeViewColumn column = sender as TreeViewColumn;
            foreach (TreeViewColumn c in view.Columns)
                {
                    if (c.SortColumnId != column.SortColumnId) c.SortIndicator = false;
                }

            if (currentSortColumnId == column.SortColumnId)
                {
                    if (currentSortType == SortType.Ascending) currentSortType = SortType.Descending;
                    else currentSortType = SortType.Ascending;
                }
            else
                {
                    currentSortColumnId = column.SortColumnId;
                    currentSortType = SortType.Ascending;
                }

            column.SortOrder = currentSortType;
            column.SortIndicator = true;
            store.SetSortColumnId (currentSortColumnId, currentSortType);
        }
Esempio n. 24
0
 private void OnSortChanged(SortType value)
 {
     view.SortType = sort = value;
 }
Esempio n. 25
0
 public SortingOptions(Expression <Func <T, object> > keySelector, bool isDescending = false) : this()
 {
     this.sortType     = SortType.SortByExp;
     this.isDescending = isDescending;
     this.keySelector  = keySelector;
 }
Esempio n. 26
0
 public void ThenSortBy(string sortProperty, bool isDescending = false)
 {
     this.thenSortType         = SortType.SortByField;
     this.thenOrderBy          = sortProperty;
     this.thenSortIsDescending = isDescending;
 }
Esempio n. 27
0
 public SortPropOrFieldAndDirection(string sPropOrFieldNameToSort, bool fDescendingSort, SortType sortTyp, StringComparison stringComp)
 {
     sPropertyOrFieldName = sPropOrFieldNameToSort;
     fSortDescending      = fDescendingSort;
     sortType             = sortTyp;
     stringComparison     = stringComp;
 }
Esempio n. 28
0
 public INetSqlQueryable <TEntity, TEntity2, TEntity3, TEntity4, TEntity5, TEntity6, TEntity7> Order <TKey>(Expression <Func <TEntity, TEntity2, TEntity3, TEntity4, TEntity5, TEntity6, TEntity7, TKey> > expression, SortType sortType)
 {
     QueryBody.SetOrderBy(expression, sortType);
     return(this);
 }
Esempio n. 29
0
        /// <summary>
        /// 得到枚举类型定义的所有文本
        /// </summary>
        /// <exception cref="NotSupportedException"></exception>
        /// <param name="enumType">枚举类型</param>
        /// <param name="sortType">指定排序类型</param>
        /// <returns>所有定义的文本</returns>
        public static EnumDescription[] GetFieldTexts(Type enumType, SortType sortType)
        {
            EnumDescription[] descriptions = null;
            //缓存中没有找到,通过反射获得字段的描述信息
            if (cachedEnum.Contains(enumType.FullName) == false)
            {
                FieldInfo[] fields = enumType.GetFields();
                ArrayList   edAL   = new ArrayList();
                foreach (FieldInfo fi in fields)
                {
                    object[] eds = fi.GetCustomAttributes(typeof(EnumDescription), false);
                    if (eds.Length != 1)
                    {
                        continue;
                    }
                    ((EnumDescription)eds[0]).fieldIno = fi;
                    edAL.Add(eds[0]);
                }

                cachedEnum.Add(enumType.FullName, (EnumDescription[])edAL.ToArray(typeof(EnumDescription)));
            }
            descriptions = (EnumDescription[])cachedEnum[enumType.FullName];
            if (descriptions.Length <= 0)
            {
                throw new NotSupportedException("枚举类型[" + enumType.Name + "]未定义属性EnumValueDescription");
            }

            //按指定的属性冒泡排序
            for (int m = 0; m < descriptions.Length; m++)
            {
                //默认就不排序了
                if (sortType == SortType.Default)
                {
                    break;
                }

                for (int n = m; n < descriptions.Length; n++)
                {
                    EnumDescription temp;
                    bool            swap = false;

                    switch (sortType)
                    {
                    case SortType.Default:
                        break;

                    case SortType.DisplayText:
                        if (string.Compare(descriptions[m].EnumDisplayText, descriptions[n].EnumDisplayText) > 0)
                        {
                            swap = true;
                        }
                        break;

                    case SortType.Rank:
                        if (descriptions[m].EnumRank > descriptions[n].EnumRank)
                        {
                            swap = true;
                        }
                        break;
                    }

                    if (swap)
                    {
                        temp            = descriptions[m];
                        descriptions[m] = descriptions[n];
                        descriptions[n] = temp;
                    }
                }
            }

            return(descriptions);
        }
Esempio n. 30
0
 public long SortAndStore(string destination, long skip = 0, long take = -1, Order order = Order.Ascending, SortType sortType = SortType.Numeric, T by = default(T), T[] get = null, CommandFlags flags = CommandFlags.None) => Wrapper.Database.SortAndStore($"{Wrapper.KeyPrefix}{RedisManager.RedisConfiguration.KeySeparator}{destination}", _realKey, skip, take, order, sortType,
                                                                                                                                                                                                                                                              Wrapper.Wrap(by), get?.Select(_ => Wrapper.Wrap(_)).ToArray(), flags);
Esempio n. 31
0
 public T[] Sort(long skip = 0, long take = -1, Order order = Order.Ascending, SortType sortType = SortType.Numeric, T by = default(T), T[] get = null, CommandFlags flags = CommandFlags.None) => Wrapper.Unwrap <T>(
     () => Wrapper.Database
     .Sort(_realKey, skip, take, order, sortType, Wrapper.Wrap(by),
           get?.Select(_ => Wrapper.Wrap(_)).ToArray(), flags)
     );
Esempio n. 32
0
 /// <summary>
 /// 解析函数
 /// </summary>
 /// <param name="callExp"></param>
 /// <param name="funcName"></param>
 /// <param name="sortType"></param>
 private void ResolveSelectForFunc(MethodCallExpression callExp, string funcName, SortType sortType)
 {
     if (callExp.Arguments[0] is UnaryExpression unary && unary.Operand is LambdaExpression lambda)
     {
         var colName = GetColumnName(lambda.Body as MemberExpression, lambda);
         Sorts.Add(new Sort($"{funcName}({colName})", sortType));
     }
 }
Esempio n. 33
0
 private void SetOrderByForSubstring(MethodCallExpression callExp, LambdaExpression fullExpression, SortType sortType)
 {
     if (callExp.Object is MemberExpression objExp && objExp.Expression.NodeType == ExpressionType.Parameter)
     {
         var funcName = _sqlAdapter.FuncSubstring;
         var colName  = GetColumnName(objExp, fullExpression);
         var start    = ((ConstantExpression)callExp.Arguments[0]).Value.ToInt() + 1;
         if (callExp.Arguments.Count > 1 || _sqlAdapter.SqlDialect != SqlDialect.SqlServer)
         {
             var length = ((ConstantExpression)callExp.Arguments[1]).Value.ToInt();
             var name   = $"{funcName}({colName},{start},{length})";
             Sorts.Add(new Sort(name, sortType));
         }
         else
         {
             var name = $"{funcName}({colName},{start})";
             Sorts.Add(new Sort(name, sortType));
         }
     }
 }
Esempio n. 34
0
        private void SetOrderByMethod(LambdaExpression expression, MethodCallExpression methodCallExp, SortType sortType = SortType.Asc)
        {
            var methodName = methodCallExp.Method.Name.ToUpper();

            switch (methodName)
            {
            case "SUBSTRING":
                SetOrderByForSubstring(methodCallExp, expression, sortType);
                return;

            case "COUNT":
                Sorts.Add(new Sort("COUNT(0)", sortType));
                return;

            case "SUM":
            case "AVG":
            case "MAX":
            case "MIN":
                ResolveSelectForFunc(methodCallExp, methodName, sortType);
                return;
            }
        }
Esempio n. 35
0
 private void SetOrderByForMember(MemberExpression memberExp, LambdaExpression fullExpression, SortType sortType)
 {
     if (memberExp.Expression.NodeType == ExpressionType.MemberAccess)
     {
         //分组查询
         if (IsGroupBy)
         {
             var descriptor = GroupByPropertyList.FirstOrDefault(m => m.Alias == memberExp.Member.Name);
             if (descriptor != null)
             {
                 var colName = GetColumnName(descriptor.Name, descriptor.JoinDescriptor);
                 Sorts.Add(new Sort(colName, sortType));
             }
         }
         else
         {
             if (memberExp.Expression.Type.IsString())
             {
                 var memberName = memberExp.Member.Name.Equals("Length");
                 //解析Length函数
                 if (memberName)
                 {
                     var funcName = _sqlAdapter.FuncLength;
                     var colName  = GetColumnName(memberExp.Expression as MemberExpression, fullExpression);
                     Sorts.Add(new Sort($"{funcName}({colName})", sortType));
                 }
             }
         }
     }
     else
     {
         var colName = GetColumnName(memberExp, fullExpression);
         Sorts.Add(new Sort(colName, sortType));
     }
 }
Esempio n. 36
0
File: Msg.cs Progetto: rsdn/janus
		private static List<MsgBase> GetOldStyleTopicList(
			IServiceProvider provider,
			int forumId,
			SortType sort,
			bool loadAll,
			MsgBase parent)
		{
			using (var db = provider.CreateDBContext())
			{
				var displayConfig = Config.Instance.ForumDisplayConfig;
				var q =
					AppendSortPredicate(db.TopicInfos(ti => ti.ForumID == forumId), sort);
				if (displayConfig.ShowUnreadThreadsOnly)
					q = q.Where(ti => !ti.Message.IsRead || ti.AnswersUnread > 0);
				if (!(loadAll || displayConfig.MaxTopicsPerForum <= 0))
					q = q.Take(displayConfig.MaxTopicsPerForum);

				var msgs =
					q
						.Select(
							ti =>
								new Msg(provider)
								{
									Parent = parent,
									IsChild = false,

									ID = ti.MessageID,
									ParentID = 0,
									ForumID = ti.ForumID,
									Name = ti.Message.Name,
									Date = ti.Message.Date,
									Subject = ti.Message.Subject,
									UserID = ti.Message.UserID,
									UserClass = (short)ti.Message.UserClass,
									UserNick = ti.Message.UserNick,
									IsRead = ti.Message.IsRead,
									IsMarked = ti.Message.IsMarked,
									Closed = ti.Message.Closed,
									ReadReplies = ti.Message.ReadReplies,
									LastModerated = ti.Message.LastModerated,
									ArticleId = ti.Message.ArticleId,
									Rating = ti.SelfRates,
									Smiles = ti.SelfSmiles,
									Agrees = ti.SelfAgrees,
									Disagrees = ti.SelfDisagrees,
									Moderatorials = ti.SelfModeratorials,
									RepliesCount = ti.AnswersCount,
									RepliesUnread = ti.AnswersUnread,
									RepliesRate = ti.AnswersRates,
									RepliesSmiles = ti.AnswersSmiles,
									RepliesAgree = ti.AnswersAgrees,
									RepliesDisagree = ti.AnswersDisagrees,
									RepliesToMeUnread = ti.AnswersToMeUnread,
									RepliesMarked = ti.AnswersMarked,
									RepliesModeratorials = ti.AnswersModeratorials
								})
						.Cast<MsgBase>()
						.ToList();
				foreach (var msg in msgs)
					msg.EndMapping();
				return msgs;
			}
		}
Esempio n. 37
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(Ascending.GetHashCode() ^ (Labels != null ? Labels.GetHashCode() : 0) ^ Open.GetHashCode() ^ Since.GetHashCode() ^ SortType.GetHashCode() ^ (Mentioned != null ? Mentioned.GetHashCode() : 0) ^ (Creator != null ? Creator.GetHashCode() : 0) ^ (Assignee != null ? Assignee.GetHashCode() : 0) ^ (Milestone != null ? Milestone.GetHashCode() : 0));
     }
 }
Esempio n. 38
0
 /// <summary>
 /// 构造器
 /// </summary>
 /// <param name="mColName"></param>
 public QueryFieldItem(String mColName)
 {
     ProjectName = string.Empty;
     ColName = mColName;
     IsShow = false;
     sortType = SortType.NoSort;
 }
Esempio n. 39
0
 /// <summary>
 /// Sorts the list according to the point values at the specified index and
 /// for the specified axis.
 /// </summary>
 public void Sort(SortType type, int index)
 {
     this.Sort(new CurveItem.Comparer(type, index));
 }
Esempio n. 40
0
        private List <Activities> GetSortedList(int startSortingAt, List <Activities> activitiesList, SortType sortType)
        {
            var baseList = activitiesList;

            if (startSortingAt == 0)
            {
                if (sortType == SortType.Ascending)
                {
                    baseList = baseList.OrderBy(x => x.ActivityDescription).ToList();
                }
                if (sortType == SortType.Descending)
                {
                    baseList = baseList.OrderByDescending(x => x.ActivityDescription).ToList();
                }
                foreach (var child in baseList)
                {
                    SortList(sortType, child);
                }
            }
            else
            {
                var lookingFor = baseList.Select(item => Activities.Find(item, startSortingAt)).FirstOrDefault(activity => activity != null);
                SortList(sortType, lookingFor);
            }

            return(baseList);
        }
Esempio n. 41
0
 public void ThenSortBy(Expression <Func <T, object> > keySelector, bool isDescending = false)
 {
     this.thenSortType         = SortType.SortByExp;
     this.thenKeySelector      = keySelector;
     this.thenSortIsDescending = isDescending;
 }
Esempio n. 42
0
File: Sort.cs Progetto: effun/nabla
 public Sort(string propertyName, SortType sortType, int sortOrder)
 {
     PropertyName = propertyName;
     SortType     = sortType;
     SortOrder    = sortOrder;
 }
Esempio n. 43
0
 public VideoFolder SortList(SortType sorttype, VideoFolder parent)
 {
     return(GetSortService.SortList(sorttype, parent));
 }
Esempio n. 44
0
 public void GetRootDetails(SortType sorttype, ref VideoFolder ParentDir)
 {
     ParentDir.FileType = FileType.Folder;
     ParentDir          = SortList(sorttype, ParentDir);
 }
Esempio n. 45
0
 public SortingOptions(long columnIndex, bool isDescending = false) : this()
 {
     this.sortType     = SortType.SortByExp;
     this.isDescending = isDescending;
     this.columnIndex  = columnIndex;
 }
Esempio n. 46
0
        public VideoFolder LoadParentFiles(VideoFolder Parentdir, IList <DirectoryInfo> SubDirectory, IList <FileInfo> SubFiles, SortType sorttype)
        {
            VideoFolder videoFolder = new VideoFolder(Parentdir, SubDirectory[0].Parent.FullName);
            var         children    = new ObservableCollection <VideoFolder>();

            children = LoadChildrenFiles(videoFolder, SubFiles);
            LoadParentSubDirectories(SubDirectory, children, videoFolder);
            videoFolder.OtherFiles = children;
            GetFolderItems(videoFolder);
            MovieDataSource.InitFileLoading();

            return(videoFolder);
        }
Esempio n. 47
0
 public SortingOptions(string sortProperty, bool isDescending = false) : this()
 {
     this.sortType     = SortType.SortByField;
     this.isDescending = isDescending;
     this.orderBy      = sortProperty;
 }
Esempio n. 48
0
 public QuickDualPivotSortBinaryInsertTests()
 {
     sort      = new QuickDualPivotSortBinaryInsert <int>();
     algorithm = nameof(QuickDualPivotSortBinaryInsert <int>);
     sortType  = SortType.Partition;
 }
Esempio n. 49
0
 public SortPropOrFieldAndDirection(string sPropOrFieldNameToSort, SortType sortTyp)
 {
     sPropertyOrFieldName = sPropOrFieldNameToSort;
     sortType             = sortTyp;
 }
Esempio n. 50
0
        /// <summary>
        /// Processes a single file.
        /// </summary>
        /// <param name="type">
        /// The sort type to use.
        /// </param>
        /// <param name="file">
        /// The file to process.
        /// </param>
        /// <param name="destination">
        /// The destination to process the files to.
        /// </param>
        private void ProcessFile(SortType type, FileResult file, IDirectoryInfo destination)
        {
            IFileInfo destinationInfo = file.GetFullPath(destination, this.storageProvider);
            if (destinationInfo.Directory != null && !destinationInfo.Directory.Exists)
            {
                destinationInfo.Directory.Create();
            }
            else
            {
                if (!this.HandleRenameAndOverwrite(file, destination, ref destinationInfo))
                {
                    return;
                }
            }

            if (destinationInfo.Exists)
            {
                Logger.OnLogMessage(this, "Skipping {0}. Already exists.", LogType.Info, destinationInfo.Name.Truncate());
                return;
            }

            switch (type)
            {
                case SortType.Move:
                    file.InputFile.MoveTo(destinationInfo.FullName);
                    Logger.OnLogMessage(this, "Moved {0}", LogType.Info, file.InputFile.Name.Truncate());
                    if (this.settings.DeleteEmptySubdirectories)
                    {
                        this.DeleteEmptySubdirectories(file);
                    }

                    break;
                case SortType.Copy:
                    file.InputFile.CopyTo(destinationInfo.FullName);
                    Logger.OnLogMessage(this, "Copied {0}", LogType.Info, file.InputFile.Name.Truncate());
                    break;
            }

            foreach (var episode in file.Episodes)
            {
                episode.FileCount++;
                episode.Save(this.storageProvider);
            }
        }
Esempio n. 51
0
File: Msg.cs Progetto: rsdn/janus
		private static IQueryable<ITopicInfo> AppendSortPredicate(
			IQueryable<ITopicInfo> source,
			SortType sort)
		{
			switch (sort)
			{
				case SortType.ByLastUpdateDateDesc:
					return source.OrderByDescending(ti => ti.LastUpdateDate);
				case SortType.ByLastUpdateDateAsc:
					return source.OrderBy(ti => ti.LastUpdateDate ?? ti.Message.Date);
				case SortType.ByDateAsc:
					return source.OrderBy(ti => ti.Message.Date);
				case SortType.ByDateDesc:
					return source.OrderByDescending(ti => ti.Message.Date);
				case SortType.ByIdAsc:
					return source.OrderBy(ti => ti.MessageID);
				case SortType.ByIdDesc:
					return source.OrderByDescending(ti => ti.MessageID);
				case SortType.BySubjectAsc:
					return source.OrderBy(ti => ti.Message.Subject);
				case SortType.BySubjectDesc:
					return source.OrderByDescending(ti => ti.Message.Subject);
				case SortType.ByAuthorAsc:
					return source.OrderBy(ti => ti.Message.UserNick);
				case SortType.ByAuthorDesc:
					return source.OrderByDescending(ti => ti.Message.UserNick);
				//case SortType.ByForumAsc:
				//case SortType.ByForumDesc:
				default:
					throw new ArgumentOutOfRangeException("sort");
			}
		}
Esempio n. 52
0
 public SortFieldAndDirection(string sPropOrFieldNameToSort, bool fDescendingSort, SortType sortTyp) : base(sPropOrFieldNameToSort, fDescendingSort, sortTyp)
 {
 }
Esempio n. 53
0
        void FilterAndSort(SortType sort)
		{
            if (_currentSort != sort)
            {
                User.Default.CurrentSort = (int)sort;
                User.Default.Save();
                _currentSort = sort;
            }

            if (_taskList != null)
            {
                var selected = lbTasks.SelectedItem as Task;
                var selectedIndex = lbTasks.SelectedIndex;


                lbTasks.ItemsSource = _taskList.Sort(_currentSort, User.Default.FilterCaseSensitive, User.Default.FilterText);

			    if (selected == null)
			    {
				    lbTasks.SelectedIndex = 0;
			    }
			    else
                {
                    object match = null;
                    foreach (var item in lbTasks.Items)
                    {
                        if (((Task)item).Body.Equals(selected.Body, StringComparison.InvariantCultureIgnoreCase))
                        {
                            match = item;
                            break;
                        }
                    }

                    if (match == null)
                    {
                        lbTasks.SelectedIndex = selectedIndex;
                    }
                    else
                    {
                        lbTasks.SelectedItem = match;
                        lbTasks.ScrollIntoView(match);
                    }
                }
            }
		}
        public async Task <List <Product> > LoadProductsInCategory(string categoryId, int offset = 0, int count = 10, string searchText = null, List <ApplyedFilter> filters = null, SortType sort = null)
        {
            await Task.Delay(500);

            if (offset > 20)
            {
                return(new List <Product>());
            }

            return(string.IsNullOrEmpty(searchText) ?
                   _products.Select(x => { x.Name = x.Name + categoryId; return x; }).ToList()
                             :
                   _products.Where(x => searchText.Contains(" ") ? searchText.ToLowerInvariant().Split(' ').Any(y => x.Name.ToLowerInvariant().Contains(y)) : x.Name.ToLowerInvariant().Contains(searchText.ToLowerInvariant())).ToList());
        }
Esempio n. 55
0
        /// <summary>
        /// Processes the specified list of files.
        /// </summary>
        /// <param name="files">
        /// The list of files to process. 
        /// </param>
        /// <param name="type">
        /// The operation to perform on the files. 
        /// </param>
        /// <param name="defaultDestination">
        /// The destination to process the files into.
        /// </param>
        internal void ProcessFiles(IEnumerable<FileResult> files, SortType type, IDirectoryInfo defaultDestination)
        {
            foreach (FileResult file in files)
            {
                if (file.Incomplete)
                {
                    Logger.OnLogMessage(this, "Skipping {0}. Not enough information.", LogType.Error, file.InputFile.Name.Truncate());
                    continue;
                }

                var showDestination = defaultDestination;
                if (file.Show.UseCustomDestination)
                {
                    showDestination = file.Show.GetCustomDestinationDirectory();
                }

                this.ProcessFile(type, file, showDestination);
            }
        }
Esempio n. 56
0
 /// <summary>
 /// Constructor for PointPairComparer.
 /// </summary>
 /// <param name="type">The axis type on which to sort.</param>
 public PointPairComparer(SortType type)
 {
     this.sortType = type;
 }
Esempio n. 57
0
 public static void Sort <T>(T[] array, SortType sortType) where T : IComparable, new()
 {
     SortIteration(array, array.Length, sortType);
 }
Esempio n. 58
0
 public SortPropertyAndDirection(string sPropOrFieldNameToSort, SortType sortTyp) : base(sPropOrFieldNameToSort, sortTyp)
 {
 }
Esempio n. 59
0
 /// <summary>
 /// Constructor for PointPairComparer.
 /// </summary>
 /// <param name="type">The axis type on which to sort.</param>
 public PointPairComparer( SortType type )
 {
     this.sortType = type;
 }
Esempio n. 60
0
File: Sort.cs Progetto: effun/nabla
 public Sort(string propertyName, SortType sortType)
     : this(propertyName, sortType, 0)
 {
 }