当前位置: 首页>>代码示例>>C#>>正文


C# SortType.ToString方法代码示例

本文整理汇总了C#中SortType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# SortType.ToString方法的具体用法?C# SortType.ToString怎么用?C# SortType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortType的用法示例。


在下文中一共展示了SortType.ToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetList

        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;
        }
开发者ID:SkiTiSu,项目名称:BiliRanking,代码行数:19,代码来源:BiliParse.cs

示例2: SortList

        public static IEnumerable<Task> SortList(SortType sort, List<Task> tasks)
        {
            Log.Debug("Sorting {0} tasks by {1}", tasks.Count().ToString(), sort.ToString());

            switch (sort)
            {
                // nb, we sub-sort by completed for most sorts by prepending either a or z
                case SortType.Completed:
                    return tasks.OrderBy(t => t.Completed);
                case SortType.Context:
                    return tasks.OrderBy(t =>
                    {
                        var s = t.Completed ? "z" : "a";
                        if (t.Contexts != null && t.Contexts.Count > 0)
                            s += t.Contexts.Min().Substring(1);
                        else
                            s += "zzz";
                        return s;
                    });
                case SortType.Alphabetical:
                    return tasks.OrderBy(t => (t.Completed ? "z" : "a") + t.Raw);
                case SortType.DueDate:
                    return tasks.OrderBy(t => (t.Completed ? "z" : "a") + (string.IsNullOrEmpty(t.DueDate) ? "9999-99-99" : t.DueDate));
                case SortType.Priority:
                    return tasks.OrderBy(t => (t.Completed ? "z" : "a") + (string.IsNullOrEmpty(t.Priority) ? "(z)" : t.Priority));
                case SortType.Project:
                    return tasks.OrderBy(t =>
                    {
                        var s = t.Completed ? "z" : "a";
                        if (t.Projects != null && t.Projects.Count > 0)
                            s += t.Projects.Min().Substring(1);
                        else
                            s += "zzz";
                        return s;
                    });
                case SortType.None:
                default:
                    return tasks;
            }
        }
开发者ID:slideep,项目名称:todotxt.net,代码行数:40,代码来源:TaskList.cs

示例3: CreatePropertiesField

        /// <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);
        }
开发者ID:krk,项目名称:LINQ-to-Wiki,代码行数:28,代码来源:ModuleGeneratorBase.cs

示例4: PagOffersForAdmin

        // vratit ce current page ako je veci od maksimalnog broja stranica
        // ova metoda koristi se u adminu pa nece popuniti property-e: FirstImgSrc, OfferTitle i ContentShort
        public static List<Offer> PagOffersForAdmin(SortType sortBy, bool isAsc, int pageNum, int numOfRows, int? active, out int totalPageCount, out int validPagNum)
        {
            List<Offer> lst = new List<Offer>();

            using (SqlConnection con = new SqlConnection(PutovalicaUtil.GetConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand()
                {
                    Connection = con,
                    CommandType = CommandType.StoredProcedure,
                    CommandText = "Collective_PagOffersForAdmin"
                })
                {
                    cmd.Parameters.Add(new SqlParameter("@SortBy", SqlDbType.VarChar, 50) { Value = sortBy.ToString() });
                    cmd.Parameters.Add(new SqlParameter("@SortAsc", SqlDbType.Bit, 1) { Value = isAsc });
                    cmd.Parameters.Add(new SqlParameter("@RowCount", SqlDbType.Int, 4) { Value = numOfRows });

                    if (active.HasValue)
                    {
                        cmd.Parameters.Add(new SqlParameter("@Active", SqlDbType.Bit, 1) { Value = active.Value });
                    }

                    SqlParameter parCurrPage = new SqlParameter("@PageNum", SqlDbType.Int, 4) { Value = pageNum, Direction = ParameterDirection.InputOutput };
                    cmd.Parameters.Add(parCurrPage);

                    SqlParameter parTotalPageCount = new SqlParameter("@TotalPageCount", SqlDbType.Int, 4) { Direction = ParameterDirection.Output };
                    cmd.Parameters.Add(parTotalPageCount);

                    con.Open();
                    using (SqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {
                            lst.Add(new Offer(
                                Convert.ToInt32(rdr["OfferId"]),
                                rdr["AdvertId"] != DBNull.Value ? (int?)Convert.ToInt32(rdr["AdvertId"]) : null,
                                rdr["AgencyId"] != DBNull.Value ? (int?)Convert.ToInt32(rdr["AgencyId"]) : null,
                                Convert.ToInt32(rdr["CollectiveCategoryId"]),
                                rdr["OfferName"].ToString(),
                                Convert.ToDouble(rdr["PriceReal"]),
                                Convert.ToDouble(rdr["PriceSave"]),
                                Convert.ToDouble(rdr["Price"]),
                                Convert.ToInt32(rdr["CurrencyId"]),
                                (OfferStatusType)Convert.ToChar(rdr["OfferStatus"]),
                                rdr["CategoryName"].ToString(),
                                rdr["Discount"] != DBNull.Value ? (double?)Convert.ToDouble(rdr["Discount"]) : null,
                                Convert.ToDateTime(rdr["DateStart"]),
                                Convert.ToDateTime(rdr["DateEnd"]),
                                Convert.ToDateTime(rdr["DateCouponStart"]),
                                Convert.ToDateTime(rdr["DateCouponEnd"]),
                                rdr["NumberOfPersons"] != DBNull.Value ? (int?)Convert.ToInt32(rdr["NumberOfPersons"]) : null,
                                rdr["NumberOfCouponsPerUser"] != DBNull.Value ? (int?)Convert.ToInt32(rdr["NumberOfCouponsPerUser"]) : null,
                                Convert.ToInt32(rdr["MinBoughtCount"]),
                                Convert.ToInt32(rdr["MaxBoughtCount"]),
                                Convert.ToInt32(rdr["BoughtCount"]),
                                Convert.ToInt32(rdr["ClickCount"]),
                                rdr["OfferType"] != DBNull.Value ? rdr["OfferType"].ToString() : null,
                                rdr["Longitude"] != DBNull.Value ? (double?)Convert.ToDouble(rdr["Longitude"]) : null,
                                rdr["Latitude"] != DBNull.Value ? (double?)Convert.ToDouble(rdr["Latitude"]) : null,
                                Convert.ToInt32(rdr["Priority"]),
                                Convert.ToBoolean(rdr["Active"])
                                )
                                {
                                    IsClientDataSet = false
                                });
                        }

                        rdr.Close();

                        totalPageCount = Convert.ToInt32(parTotalPageCount.Value);
                        validPagNum = Convert.ToInt32(parCurrPage.Value);
                    }
                    con.Close();
                }
            }

            return lst;
        }
开发者ID:bneuhold,项目名称:pb-dev,代码行数:80,代码来源:Offer.cs


注:本文中的SortType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。