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


C# IOrderedEnumerable.Count方法代码示例

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


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

示例1: Percentile

        private double Percentile(IOrderedEnumerable<double> sortedData, double p)
        {
            int count = sortedData.Count();
            if (count == 0) return 0;
            if (count == 1) return sortedData.Last();
            if (p >= 100.0d) return sortedData.Last();

            double position = (count + 1) * p / 100d;
            double leftNumber, rightNumber;

            double n = p / 100d * (count - 1) + 1d;

            if (position >= 1)
            {
                leftNumber = sortedData.ElementAt((int)Math.Floor(n) - 1);
                rightNumber = sortedData.ElementAt((int)Math.Floor(n));
            }
            else
            {
                leftNumber = sortedData.First();
                rightNumber = sortedData.ElementAt(1);
            }

            if (Math.Abs(leftNumber - rightNumber) < Double.Epsilon)
                return leftNumber;
            else
            {
                double part = n - Math.Floor(n);
                return leftNumber + part*(rightNumber - leftNumber);
            }
        }
开发者ID:demonix,项目名称:iPoint.ServiceStatistics,代码行数:31,代码来源:PercentileAggregationOperation.cs

示例2: ObserverShroudSelectorLogic

        public ObserverShroudSelectorLogic(Widget widget, World world)
        {
            var groups = new Dictionary<string, IEnumerable<CameraOption>>();

            teams = world.Players.Where(p => !p.NonCombatant)
                .Select(p => new CameraOption(this, p))
                .GroupBy(p => (world.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team)
                .OrderBy(g => g.Key);

            var noTeams = teams.Count() == 1;
            foreach (var t in teams)
            {
                var label = noTeams ? "Players" : t.Key == 0 ? "No Team" : "Team {0}".F(t.Key);
                groups.Add(label, t);
            }

            combined = new CameraOption(this, world, "All Players", world.Players.First(p => p.InternalName == "Everyone"));
            disableShroud = new CameraOption(this, world, "Disable Shroud", null);
            groups.Add("Other", new List<CameraOption>() { combined, disableShroud });

            var shroudSelector = widget.Get<DropDownButtonWidget>("SHROUD_SELECTOR");
            shroudSelector.OnMouseDown = _ =>
            {
                Func<CameraOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
                {
                    var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
                    var showFlag = option.Race != null;

                    var label = item.Get<LabelWidget>("LABEL");
                    label.IsVisible = () => showFlag;
                    label.GetText = () => option.Label;
                    label.GetColor = () => option.Color;

                    var flag = item.Get<ImageWidget>("FLAG");
                    flag.IsVisible = () => showFlag;
                    flag.GetImageCollection = () => "flags";
                    flag.GetImageName = () => option.Race;

                    var labelAlt = item.Get<LabelWidget>("NOFLAG_LABEL");
                    labelAlt.IsVisible = () => !showFlag;
                    labelAlt.GetText = () => option.Label;
                    labelAlt.GetColor = () => option.Color;

                    return item;
                };

                shroudSelector.ShowDropDown("SPECTATOR_DROPDOWN_TEMPLATE", 400, groups, setupItem);
            };

            var shroudLabel = shroudSelector.Get<LabelWidget>("LABEL");
            shroudLabel.IsVisible = () => selected.Race != null;
            shroudLabel.GetText = () => selected.Label;
            shroudLabel.GetColor = () => selected.Color;

            var shroudFlag = shroudSelector.Get<ImageWidget>("FLAG");
            shroudFlag.IsVisible = () => selected.Race != null;
            shroudFlag.GetImageCollection = () => "flags";
            shroudFlag.GetImageName = () => selected.Race;

            var shroudLabelAlt = shroudSelector.Get<LabelWidget>("NOFLAG_LABEL");
            shroudLabelAlt.IsVisible = () => selected.Race == null;
            shroudLabelAlt.GetText = () => selected.Label;
            shroudLabelAlt.GetColor = () => selected.Color;

            var keyhandler = shroudSelector.Get<LogicKeyListenerWidget>("SHROUD_KEYHANDLER");
            keyhandler.OnKeyPress = HandleKeyPress;

            selected = disableShroud;
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:69,代码来源:ObserverShroudSelectorLogic.cs

示例3: GetQuartile

        private static double GetQuartile(IOrderedEnumerable<double> list, double quartile)
        {
            double result;

            // Get roughly the index
            double index = quartile * (list.Count() + 1);

            // Get the remainder of that index value if exists
            double remainder = index % 1;

            // Get the integer value of that index
            index = Math.Floor(index) - 1;

            if (remainder.Equals(0))
            {
                // we have an integer value, no interpolation needed
                result = list.ElementAt((int)index);
            }
            else
            {
                // we need to interpolate
                double value = list.ElementAt((int)index);
                double interpolationValue = value
                    .Interpolate(list.ElementAt((int)(index + 1)), remainder);

                result = value + interpolationValue;
            }

            return result;
        }
开发者ID:mythsya,项目名称:db-plugins,代码行数:30,代码来源:MathUtil.cs

示例4: Export

 /// <summary>
 /// Exports the queue with the current set of builds and the default or last used filename.
 /// </summary>
 /// <param name="queueBuilds"></param>
 /// <param name="results"></param>
 public static void Export(this QueueBuilds queueBuilds, IOrderedEnumerable<IQueuedBuild> results)
 {
     queueBuilds.WriteHeaders();
     queueBuilds.WriteBody(results);
     queueBuilds.WriteFooter(results.Count());
 }
开发者ID:carlowahlstedt,项目名称:TFSBuildQueue,代码行数:11,代码来源:Extensions.cs

示例5: Execute


//.........这里部分代码省略.........
                columnheader = new ColumnHeader();
                columnheader.Text = "Weight";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Attack";
                listView1.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "SpecialAttack";
                listView1.Columns.Add(columnheader);

                foreach (var pokemon in pokemons)
                {
                    Bitmap pokemonImage = null;
                    await Task.Run(() =>
                    {
                        pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                    });
                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                    listView1.LargeImageList = imageList;
                    var listViewItem = new ListViewItem();
                    listViewItem.Tag = pokemon;



                    var currentCandy = families
                        .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                        .Select(f => f.Candy)
                        .First();
                    var currIv = Math.Round(Perfect(pokemon));
                    listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));
                    listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", currIv, pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                    listViewItem.SubItems.Add(string.Format("{0}", currentCandy));
                    listViewItem.ImageKey = pokemon.PokemonId.ToString();

                    var pokemonId2 = pokemon.PokemonId;
                    var pokemonName = pokemon.Id;

                    listViewItem.Text = string.Format("{0}", pokemon.PokemonId);
                    listViewItem.ToolTipText = "Favorite: " + pokemon.Favorite + "\nNickname: " + pokemon.Nickname;

                    var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                    var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);

                    if (settings.EvolutionIds.Count > 0 && familyCandy.Candy > settings.CandyToEvolve)
                    {
                        listViewItem.SubItems.Add("Y ("+ settings.CandyToEvolve+")");
                        listViewItem.Checked = true;
                    }
                    else
                    {
                        if (settings.EvolutionIds.Count > 0)
                            listViewItem.SubItems.Add("N (" + familyCandy.Candy + "/" + settings.CandyToEvolve + ")");
                        else
                            listViewItem.SubItems.Add("N (Max)");
                    }
                    listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                    listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg,2)));
                    listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                    listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move2));

                    listView1.Items.Add(listViewItem);
                }
                listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                Text = "Pokemon List | User: " + profile.Profile.Username + " | Pokemons: " + pokemons.Count() + "/" + profile.Profile.PokeStorage;
                EnabledButton(true);

                textBox1.Text = string.Empty;
            }
            catch (TaskCanceledException e)
            {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (UriFormatException e)
            {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (ArgumentOutOfRangeException e)
            {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (ArgumentNullException e)
            {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (NullReferenceException e)
            {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (Exception e)
            {
                textBox1.Text = e.Message;
                Execute();
            }
        }
开发者ID:ZimboBoyd,项目名称:PokeBot3,代码行数:101,代码来源:Pokemons.cs

示例6: Execute

        private async void Execute()
        {
            EnabledButton(false);
            textBox1.Text = "Reloading Pokemon list.";

            client = new Client(ClientSettings);

            try
            {
                switch (ClientSettings.AuthType)
                {
                    case AuthType.Ptc:
                        await client.DoPtcLogin(ClientSettings.PtcUsername, ClientSettings.PtcPassword);
                        break;
                    case AuthType.Google:
                        await client.DoGoogleLogin();
                        break;
                }

                await client.SetServer();
                profile = await client.GetProfile();
                inventory = await client.GetInventory();
                pokemons =
                    inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.Pokemon)
                        .Where(p => p != null && p?.PokemonId > 0)
                        .OrderByDescending(key => key.Cp);
                var families = inventory.InventoryDelta.InventoryItems
                    .Select(i => i.InventoryItemData?.PokemonFamily)
                    .Where(p => p != null && (int)p?.FamilyId > 0)
                    .OrderByDescending(p => (int)p.FamilyId);

                var imageSize = 50;

                var imageList = new ImageList { ImageSize = new Size(imageSize, imageSize) };
                listView1.ShowItemToolTips = true;

                var templates = await client.GetItemTemplates();
                var myPokemonSettings =  templates.ItemTemplates.Select(i => i.PokemonSettings).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                var pokemonSettings = myPokemonSettings.ToList();

                var myPokemonFamilies = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonFamily).Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
                var pokemonFamilies = myPokemonFamilies.ToArray();

                listView1.DoubleBuffered(true);
                foreach (var pokemon in pokemons)
                {
                    Bitmap pokemonImage = null;
                    await Task.Run(() =>
                    {
                        pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                    });
                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                    listView1.LargeImageList = imageList;
                    var listViewItem = new ListViewItem();
                    listViewItem.Tag = pokemon;


                    var currentCandy = families
                        .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                        .Select(f => f.Candy)
                        .First();
                    var currIv = Math.Round(Perfect(pokemon));
                    //listViewItem.SubItems.Add();
                    listViewItem.ImageKey = pokemon.PokemonId.ToString();

                    var pokemonId2 = pokemon.PokemonId;
                    var pokemonName = pokemon.Id;

                    listViewItem.Text = string.Format("{0}\n{1} CP", pokemon.PokemonId, pokemon.Cp);
                    listViewItem.ToolTipText = currentCandy + " Candy\n" + currIv + "% IV";

                    var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                    var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);

                    if (settings.EvolutionIds.Count > 0 && familyCandy.Candy > settings.CandyToEvolve)
                        listViewItem.Checked = true;

                    listView1.Items.Add(listViewItem);
                }
                Text = "Pokemon List | User: " + profile.Profile.Username + " | Pokemons: " + pokemons.Count() + "/" + profile.Profile.PokeStorage;
                EnabledButton(true);

                textBox1.Text = string.Empty;
            }
            catch (TaskCanceledException e) {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (UriFormatException e) {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (ArgumentOutOfRangeException e) {
                textBox1.Text = e.Message;
                Execute();
            }
            catch (ArgumentNullException e) {
                textBox1.Text = e.Message;
//.........这里部分代码省略.........
开发者ID:ReeViiS69,项目名称:PokemonGo-Bot,代码行数:101,代码来源:Pokemons.cs

示例7: GetListOfTrades

        private List<string> GetListOfTrades(string player, IOrderedEnumerable<KeyValuePair<string, double>> tradeList, bool topDown)
        {
            List<string> results = new List<string>();

            if (topDown)
            {
                for (int i = 0; i < tradeList.Count(); i++)
                {
                    if (tradeList.ElementAt(i).Key == player)
                    {
                        break;
                    }

                    results.Add(tradeList.ElementAt(i).Key);
                }
            }
            else
            {
                for (int i = tradeList.Count() - 1; i >= 0; i--)
                {
                    if (tradeList.ElementAt(i).Key == player)
                    {
                        break;
                    }

                    results.Add(tradeList.ElementAt(i).Key);
                }
            }
            return results;
        }
开发者ID:spazer,项目名称:FPL_Calculator,代码行数:30,代码来源:Stats.cs

示例8: Execute


//.........这里部分代码省略.........
                PokemonListView.View = View.Details;

                ColumnHeader columnheader;
                columnheader = new ColumnHeader();
                columnheader.Text = "Name";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "CP";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "IV A-D-S";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "LVL";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Evolvable?";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Height";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Weight";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "HP";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "Attack";
                PokemonListView.Columns.Add(columnheader);
                columnheader = new ColumnHeader();
                columnheader.Text = "SpecialAttack";
                PokemonListView.Columns.Add(columnheader);

                foreach (var pokemon in pokemons)
                {
                    Bitmap pokemonImage = null;
                    await Task.Run(() =>
                    {
                        pokemonImage = GetPokemonImage((int)pokemon.PokemonId);
                    });
                    imageList.Images.Add(pokemon.PokemonId.ToString(), pokemonImage);

                    PokemonListView.LargeImageList = imageList;
                    var listViewItem = new ListViewItem();
                    listViewItem.Tag = pokemon;



                    var currentCandy = families
                        .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                        .Select(f => f.Candy)
                        .First();
                    listViewItem.SubItems.Add(string.Format("{0}", pokemon.Cp));
                    listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", Math.Round(pokemon.CalculateIV()), pokemon.IndividualAttack, pokemon.IndividualDefense, pokemon.IndividualStamina));
                    listViewItem.SubItems.Add(string.Format("{0}", PokemonInfo.GetLevel(pokemon)));
                    listViewItem.ImageKey = pokemon.PokemonId.ToString();
                    
                    listViewItem.Text = string.Format((pokemon.Favorite == 1)? "{0} ★" : "{0}", pokemon.PokemonId);

                    listViewItem.ToolTipText = new DateTime((long)pokemon.CreationTimeMs * 10000).AddYears(1970).ToString("dd/MM/yyyy HH:mm:ss");
                    if (pokemon.Nickname!="")
                        listViewItem.ToolTipText += "\nNickname: " + pokemon.Nickname;

                    var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.PokemonId);
                    var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);

                    if (settings.EvolutionIds.Count > 0 && familyCandy.Candy >= settings.CandyToEvolve)
                    {
                        listViewItem.SubItems.Add("Y (" + familyCandy.Candy + "/" + settings.CandyToEvolve + ")");
                        listViewItem.Checked = true;
                    }
                    else
                    {
                        if (settings.EvolutionIds.Count > 0)
                            listViewItem.SubItems.Add("N (" + familyCandy.Candy + "/" + settings.CandyToEvolve + ")");
                        else
                            listViewItem.SubItems.Add("N (" + familyCandy.Candy + "/Max)");
                    }
                    listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.HeightM, 2)));
                    listViewItem.SubItems.Add(string.Format("{0}", Math.Round(pokemon.WeightKg, 2)));
                    listViewItem.SubItems.Add(string.Format("{0}/{1}", pokemon.Stamina, pokemon.StaminaMax));
                    listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move1));
                    listViewItem.SubItems.Add(string.Format("{0}", pokemon.Move2));

                    PokemonListView.Items.Add(listViewItem);
                }
                PokemonListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                Text = "Pokemon List | User: " + profile.Profile.Username + " | Pokemons: " + pokemons.Count() + "/" + profile.Profile.PokeStorage;
                EnabledButton(true);

                statusTexbox.Text = string.Empty;
            }
            catch (Exception e)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.Red, "Error reloading Pokemon list: " + e.Message);
                await Task.Delay(500); // Lets the API make a little pause, so we dont get blocked
                Execute();
            }
        }
开发者ID:CocoTail,项目名称:PokemonGo-Bot,代码行数:101,代码来源:Pokemons.cs

示例9: AddCorners

 private void AddCorners(IOrderedEnumerable<Pixel> cornerCandidates)
 {
     if (cornerCandidates.Count() > 50)
     {
         //First and Last point are corners
         MassureAngleAndAddCorner(cornerCandidates.First());
         MassureAngleAndAddCorner(cornerCandidates.Last());
     }
     else
     {
         // middle point is corner
         int index = cornerCandidates.Count() / 2;
         MassureAngleAndAddCorner(cornerCandidates.ElementAt(index));
     }
 }
开发者ID:rerezz,项目名称:Digitale-Bildbearbeitung,代码行数:15,代码来源:ImageObject.cs

示例10: InvokeRecursive

 private Task InvokeRecursive(int index, IOrderedEnumerable<IMOwinFilter> filters, IIMOwinOptions options, OperationContext context)
 {
     index += 1;
     return filters.Count() != index ? filters.Skip(index).First().Invoke(context, () => InvokeRecursive(index, filters, options, context)) : ExecuteOperation(options, context);
 }
开发者ID:ilovelili,项目名称:IMobile.Owin,代码行数:5,代码来源:OperationHandler.cs


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