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


C# List.Max方法代码示例

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


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

示例1: CreateCollage

        public static Bitmap CreateCollage(List<User> users, int height, int width)
        {
            const double minSliceRatio = 0.35;

            var threshold = users.Max(x => x.StatusesCount) / 20;

            var elements = users
                .Select(x => new Element<User>
                {
                    Object = x,
                    Value = x.StatusesCount < threshold ? threshold : x.StatusesCount
                })
                .OrderByDescending(x => x.Value)
                .ToList();

            var slice = Treemap.GetSlice(elements, 1, minSliceRatio);

            var rectangles = Treemap.GetRectangles(slice, width, height).ToList();

            return DrawTreemap(rectangles, width, height);
        }
开发者ID:tarbii,项目名称:Collager,代码行数:21,代码来源:Collage.cs

示例2: ShowFavoritesAsync

        static async Task ShowFavoritesAsync(TwitterContext twitterCtx)
        {
            const int PerQueryFavCount = 200;

            // set from a value that you previously saved
            ulong sinceID = 1; 

            var favsResponse =
                await
                    (from fav in twitterCtx.Favorites
                     where fav.Type == FavoritesType.Favorites &&
                           fav.Count == PerQueryFavCount
                     select fav)
                    .ToListAsync();

            if (favsResponse == null)
            {
                Console.WriteLine("No favorites returned from Twitter.");
                return;
            }

            var favList = new List<Favorites>(favsResponse);

            // first tweet processed on current query
            ulong maxID = favList.Min(fav => fav.StatusID) - 1;

            do
            {
                favsResponse =
                    await
                        (from fav in twitterCtx.Favorites
                         where fav.Type == FavoritesType.Favorites &&
                               fav.Count == PerQueryFavCount &&
                               fav.SinceID == sinceID &&
                               fav.MaxID == maxID
                         select fav)
                        .ToListAsync();

                if (favsResponse == null || favsResponse.Count == 0) break;

                // reset first tweet to avoid re-querying the
                // same list you just received
                maxID = favsResponse.Min(fav => fav.StatusID) - 1;
                favList.AddRange(favsResponse);

            } while (favsResponse.Count > 0);

            favList.ForEach(fav => 
            {
                if (fav != null && fav.User != null)
                    Console.WriteLine(
                        "Name: {0}, Tweet: {1}",
                        fav.User.ScreenNameResponse, fav.Text);
            });

            // save this in your db for this user so you can set
            // sinceID accurately the next time you do a query
            // and avoid querying the same tweets again.
            ulong newSinceID = favList.Max(fav => fav.SinceID);
        }
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:60,代码来源:FavoriteDemos.cs


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