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


C# IReadOnlyCollection.ToList方法代码示例

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


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

示例1: matchIntoAnagrams

        void matchIntoAnagrams(IReadOnlyCollection<char> source, string lexiconWord, ICollection<Anagram> anagrams)
        {
            if (lexiconWord.Length < MIN_WORD_LENGTH)
                return;

            if (lexiconWord.Length > source.Count)
                return;

            var unused = source.ToList();
            var used = new List<char>();

            foreach (var letter in lexiconWord)
            {
                if (!unused.Move(letter, used))
                    if (!unused.Move(WILDCARD, used))
                        break;
            }

            if (used.Count != lexiconWord.Length)
                return;

            var points = getTotalPoints(used);
            var anagram = new Anagram(lexiconWord, points);

            anagrams.Add(anagram);
        }
开发者ID:rmacfie,项目名称:Words,代码行数:26,代码来源:AnagramFinder.cs

示例2: CalculateWinningChance

        public float CalculateWinningChance(Card playerFirstCard, Card playerSecondCard, IReadOnlyCollection<Card> communityCards)
        {
            IList<Card> deck = this.GetDeck(playerFirstCard, playerSecondCard, communityCards);

            int cardStrengthResult = 0;

            for (int i = 0; i < SimulationsCount; i++)
            {
                var currentDeck = new Stack<Card>(deck.Shuffle());

                IList<Card> opponentCards = new List<Card> { currentDeck.Pop(), currentDeck.Pop() };

                var currentCommunityCards = communityCards.ToList();
                while (currentCommunityCards.Count < MaxCountCommunityCards)
                {
                    currentCommunityCards.Add(currentDeck.Pop());
                }

                var myHand = currentCommunityCards.ToList();
                myHand.Add(playerFirstCard);
                myHand.Add(playerSecondCard);

                var opponentHand = opponentCards.Concat(currentCommunityCards);

                int currentCardStrengthResult = Helpers.CompareCards(myHand, opponentHand);
                cardStrengthResult += currentCardStrengthResult;
            }

            float result = GetStrengthAsPercentage(cardStrengthResult, SimulationsCount);
            return result;
        }
开发者ID:g-yonchev,项目名称:Bullets,代码行数:31,代码来源:MonteCarloAlgorithm.cs

示例3: PassiveAggressiveFlopProvider

 /// <summary>
 /// Initializes a new instance of the <see cref="PassiveAggressiveFlopProvider"/> class.
 /// </summary>
 /// <param name="context">Main game logic context</param>
 /// <param name="first">First player card</param>
 /// <param name="second">Second player card<</param>
 /// <param name="isFirst">Boolean check for SmalBlind/BigBlind position</param>
 /// <param name="communityCards">The community board cards (flop, turn, river)</param>
 internal PassiveAggressiveFlopProvider(GetTurnContext context, Card first, Card second, IReadOnlyCollection<Card> communityCards, bool isFirst)
     : base(context, first, second, isFirst)
 {
     this.handEvaluator = new PreFlopHandEvaluator();
     this.communityCards = communityCards;
     this.allCards = new List<Card> { first, second };
     this.allCards.AddRange(communityCards.ToList());
 }
开发者ID:DimitarSD,项目名称:Teamwork-Sparta,代码行数:16,代码来源:PassiveAggressiveFlopProvider.cs

示例4: ScriptEngine

        public ScriptEngine( IReadOnlyCollection<string> scriptDirectories )
        {
            Contract.RequiresNotNull( scriptDirectories, "scriptDirectories" );

            myScriptDirectories = scriptDirectories.ToList();

            myScripts = new List<Script>();
            myScriptArgs = new List<string>();
            myScriptsToExecute = new List<string>();
        }
开发者ID:JackWangCUMT,项目名称:Plainion,代码行数:10,代码来源:ScriptEngine.cs

示例5: CalculateRisk

        public static CardValuationType CalculateRisk(Card leftCard, Card rightCard, IReadOnlyCollection<Card> communityCard)
        {
            var communityCards = communityCard.ToList();
            var handRankType = HandRankType.HighCard;

            var current = Get(leftCard, rightCard, communityCards[0], communityCards[1], communityCards[2]);

            if (handRankType < current)
            {
                handRankType = current;
            }

            current = Get(leftCard, rightCard, communityCards[1], communityCards[2], communityCards[3]);

            if (handRankType < current)
            {
                handRankType = current;
            }

            current = Get(leftCard, rightCard, communityCards[0], communityCards[2], communityCards[3]);

            if (handRankType < current)
            {
                handRankType = current;
            }

            current = Get(leftCard, rightCard, communityCards[0], communityCards[1], communityCards[3]);

            if (handRankType < current)
            {
                handRankType = current;
            }

            switch (handRankType)
            {
                case HandRankType.Pair:
                    return CardValuationType.Risky;
                case HandRankType.TwoPairs:
                    return CardValuationType.Recommended;
                case HandRankType.ThreeOfAKind:
                case HandRankType.Straight:
                    return CardValuationType.VeryRecommended;
                case HandRankType.Flush:
                case HandRankType.FullHouse:
                case HandRankType.FourOfAKind:
                    return CardValuationType.VeryPowerful;
                case HandRankType.StraightFlush:
                    return CardValuationType.AllIn;
                default:
                    return CardValuationType.Unplayable;
            }
        }
开发者ID:tddold,项目名称:Team-TheChurch,代码行数:52,代码来源:TurnHandStrength.cs

示例6: GetCollections

 public async Task<IReadOnlyCollection<SubscribedCollection>> GetCollections(Guid gameId,
     IReadOnlyCollection<Guid> collectionIds, IReadOnlyCollection<NetworkContent> content) {
     var contents =
         await
             DownloadCollections(new[] {Tuple.Create(gameId, collectionIds.ToList())})
                 .ConfigureAwait(false);
     if (contents.Count < collectionIds.Count)
         throw new Exception("Could not find all requested collections");
     var collections = new List<SubscribedCollection>();
     foreach (var c in contents) {
         var col = c.MapTo<SubscribedCollection>();
         HandleContent(content, col, c, await GetRepositories(col).ConfigureAwait(false));
         collections.Add(col);
     }
     return collections;
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:16,代码来源:NetworkContentSyncer.cs

示例7: Init

        internal Repository Init(IAbsoluteDirectoryPath folder, IReadOnlyCollection<Uri> hosts, SyncOptions opts) {
            var rsyncFolder = folder.GetChildDirectoryWithName(Repository.RepoFolderName);
            if (rsyncFolder.Exists)
                throw new Exception("Already appears to be a repository");

            var packFolder = GetPackFolder(opts, rsyncFolder);
            var configFile = rsyncFolder.GetChildFileWithName(Repository.ConfigFileName);
            var wdVersionFile = rsyncFolder.GetChildFileWithName(Repository.VersionFileName);
            var packVersionFile = packFolder.GetChildFileWithName(Repository.VersionFileName);

            this.Logger().Info("Initializing {0}", folder);
            rsyncFolder.MakeSurePathExists();
            packFolder.MakeSurePathExists();

            var config = new RepoConfig { Hosts = hosts.ToList() };

            config.PackPath = opts.PackPath?.ToString();

            if (opts.Include != null)
                config.Include = opts.Include;

            if (opts.Exclude != null)
                config.Include = opts.Exclude;

            var guid = opts.RequiredGuid ?? Guid.NewGuid().ToString();

            var packVersion = new RepoVersion { Guid = guid };
            if (opts.ArchiveFormat != null)
                packVersion.ArchiveFormat = (string)opts.ArchiveFormat;

            var wdVersion = SyncEvilGlobal.Yaml.NewFromYaml<RepoVersion>(packVersion.ToYaml());

            SyncEvilGlobal.Yaml.ToYamlFile(config, configFile);
            SyncEvilGlobal.Yaml.ToYamlFile(packVersion, packVersionFile);
            SyncEvilGlobal.Yaml.ToYamlFile(wdVersion, wdVersionFile);

            return TryGetRepository(folder, opts, rsyncFolder);
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:38,代码来源:RepositoryFactory.cs

示例8: ResolveRollbackActions

        private async Task<Dictionary<string, List<ScriptAction>>> ResolveRollbackActions(
            int stageId, 
            IEnumerable<ReleaseAction> actions, 
            IReadOnlyCollection<ScriptAction> scriptElements)
        {
            var rollbackActions = new Dictionary<string, List<ScriptAction>>();

            // Group the rollback action parameters
            var groupedRollbackActions =
                actions.OfType<RollbackBlock>()
                    .GroupBy(
                        g =>
                        string.Format(
                            g.DisplayNameIsMeaningful
                                ? this.meaningfulDisplayNameFolderFormat
                                : this.meaninglessDisplayNameFolderFormat, 
                            g.Sequence, 
                            g.ItemType, 
                            g.DisplayName))
                    .Select(s => new { s.Key, Item = s.First() })
                    .ToList();

            foreach (var rollbackGroup in groupedRollbackActions)
            {
                var rollbackScriptActions = new List<ScriptAction>();
                if (rollbackGroup.Item == null)
                {
                    continue;
                }

                /* Figure out which actions need rollback blocks
                   Normally, a rollback is attached to just the preceding action.
                   Rollback always blocks are attached to all of the actions in the script. Basically, if the script fails, it should always run that block.
                */
                IEnumerable<ScriptAction> scriptElementsToAttachRollbacks;
                if (rollbackGroup.Item.ItemType == BlockType.RollbackAlways)
                {
                    scriptElementsToAttachRollbacks = scriptElements.ToList();
                }
                else
                {
                    // Attach the rollback script to the action directly preceding it, and to all actions that happen after.
                    scriptElementsToAttachRollbacks =
                        scriptElements.Where(se => se.Sequence >= rollbackGroup.Item.Sequence - 1).ToList();
                }

                this.ScriptGenerationNotification?.Invoke(
                    this, 
                    GetContainerGenerationArgs(rollbackGroup.Item, ContainerStart));
                foreach (var rollbackAction in rollbackGroup.Item.SubItems.OfType<ReleaseAction>())
                {
                    this.ScriptGenerationNotification?.Invoke(
                        this, 
                        GetActionGenerationArgs(rollbackAction, ActionStart));
                    var component =
                        await this.componentRepo.GetComponentByIdAsync(rollbackAction.WorkflowActivityId, stageId);
                    await this.deployerToolRepo.WriteToolToDiskAsync(component.DeployerToolId, this.deployerToolsPath);
                    var action = CreateScriptAction(component, rollbackAction);
                    action.Sequence += rollbackGroup.Item.Sequence;
                    rollbackScriptActions.Add(action);
                    this.ScriptGenerationNotification?.Invoke(this, GetActionGenerationArgs(rollbackAction, ActionEnd));
                }

                foreach (var scriptElementToAttachRollback in scriptElementsToAttachRollbacks)
                {
                    scriptElementToAttachRollback.RollbackScripts.Add(rollbackGroup.Key, rollbackScriptActions);
                }

                rollbackActions.Add(rollbackGroup.Key, rollbackScriptActions);
                this.ScriptGenerationNotification?.Invoke(
                    this, 
                    GetContainerGenerationArgs(rollbackGroup.Item, ContainerEnd));
            }

            return rollbackActions;
        }
开发者ID:DanielBMann9000,项目名称:Migrate-assets-from-RM-server-to-VSTS,代码行数:76,代码来源:ScriptGenerator.cs

示例9: GetCollections

 public async Task<IReadOnlyCollection<SubscribedCollection>> GetCollections(Guid gameId,
     IReadOnlyCollection<Guid> collectionIds) {
     var contents =
         await DownloadCollections(new[] {Tuple.Create(gameId, collectionIds.ToList())})
             .ConfigureAwait(false);
     if (contents.Count < collectionIds.Count)
         throw new NotFoundException("Could not find all requested collections");
     var collections = new List<SubscribedCollection>();
     foreach (var c in contents)
         collections.Add(await MapCollection(c, CancellationToken.None).ConfigureAwait(false));
     return collections;
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:12,代码来源:NetworkContentSyncer.cs

示例10: HandleAia

 private IReadOnlyCollection<IContentSpec<IInstallableContent>> HandleAia(
     IReadOnlyCollection<IContentSpec<IInstallableContent>> content) {
     var info = new AiaInfo(content.Select(x => x.Content).OfType<IHavePackageName>().ToArray());
     var newModsList = content.ToList();
     if (info.HasAia() && info.HasCup()) {
         //    if (aiaSpecific != null || aiaSpecificLite != null)
         //      newModsList.Remove(Cup);
         //                else
         newModsList.RemoveAll(x => info.IsAia(x.Content));
     }
     if (info.HasCup() || info.HasAia())
         newModsList.RemoveAll(x => info.IsA3Mp(x.Content));
     return newModsList;
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:14,代码来源:Arma3Game.cs


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