本文整理汇总了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);
}
示例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;
}
示例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());
}
示例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>();
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}