本文整理汇总了C#中ICollection.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# ICollection.ToList方法的具体用法?C# ICollection.ToList怎么用?C# ICollection.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICollection
的用法示例。
在下文中一共展示了ICollection.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeContextForNode
/// <summary>
/// Initializes the context for node.
/// </summary>
/// <param name="node">The node.</param>
/// <param name="parentNode">The parent node.</param>
/// <param name="localNames">The local names.</param>
private static void InitializeContextForNode(this Node node, Node parentNode, ICollection<string> localNames)
{
if (node is IDeclarationProvider)
{
var declaringNode = (IDeclarationProvider) node;
foreach (var declaration in declaringNode.GetDeclarations())
{
if (declaration.IsLocal && !localNames.Contains(declaration.Name))
localNames.Add(declaration.Name);
}
}
if (node != null)
{
node.Context = CreateNodeContext(localNames, parentNode);
foreach (var childNode in node.GetChildNodes())
{
InitializeContextForNode(childNode, node, localNames.ToList());
}
if (node.Next != null)
{
InitializeContextForNode(node.Next, node.Parent, localNames.ToList());
}
}
}
示例2: EndGameTurn
private PlayerAction EndGameTurn(PlayerTurnContext context, ICardTracker tracker, ICollection<Card> myHand)
{
this.root = new Node(null, null, context.IsFirstPlayerTurn);
if (context.IsFirstPlayerTurn && this.root.Children.Count == 0)
{
tracker.SetFinalRoundHands(myHand);
var myCards = myHand.ToList();
EndgameAnalyzer.Compute(this.root, null, myCards, tracker.OpponentTookWith, context.SecondPlayerRoundPoints, context.FirstPlayerRoundPoints);
}
else if (this.root.Children.Count == 0)
{
tracker.SetFinalRoundHands(myHand);
var myCards = myHand.ToList();
while (tracker.OpponentTookWith.Count < 6)
{
tracker.OpponentTookWith.Add(null);
}
EndgameAnalyzer.Compute(this.root, context.FirstPlayedCard, myCards, tracker.OpponentTookWith, context.FirstPlayerRoundPoints, context.SecondPlayerRoundPoints);
}
if (!context.IsFirstPlayerTurn)
{
this.root = this.root.Children.First(x => x.Card == context.FirstPlayedCard);
}
var card = this.root.Children.OrderByDescending(x => x.Wins / (decimal)x.Total).First().Card;
return PlayerAction.PlayCard(card);
}
示例3: FigureSetIdsComposer
public FigureSetIdsComposer(ICollection<ClothingParts> ClothingParts)
: base(ServerPacketHeader.FigureSetIdsMessageComposer)
{
base.WriteInteger(ClothingParts.Count);
foreach (ClothingParts Part in ClothingParts.ToList())
{
base.WriteInteger(Part.PartId);
}
base.WriteInteger(ClothingParts.Count);
foreach (ClothingParts Part in ClothingParts.ToList())
{
base.WriteString(Part.Part);
}
}
示例4: GameAchievementListComposer
public GameAchievementListComposer(GameClient Session, ICollection<Achievement> Achievements, int GameId)
: base(ServerPacketHeader.GameAchievementListMessageComposer)
{
base.WriteInteger(GameId);
base.WriteInteger(Achievements.Count);
foreach (Achievement Ach in Achievements.ToList())
{
UserAchievement UserData = Session.GetHabbo().GetAchievementData(Ach.GroupName);
int TargetLevel = (UserData != null ? UserData.Level + 1 : 1);
AchievementLevel TargetLevelData = Ach.Levels[TargetLevel];
base.WriteInteger(Ach.Id); // ach id
base.WriteInteger(TargetLevel); // target level
base.WriteString(Ach.GroupName + TargetLevel); // badge
base.WriteInteger(TargetLevelData.Requirement); // requirement
base.WriteInteger(TargetLevelData.Requirement); // requirement
base.WriteInteger(TargetLevelData.RewardPixels); // pixels
base.WriteInteger(0); // ach score
base.WriteInteger(UserData != null ? UserData.Progress : 0); // Current progress
base.WriteBoolean(UserData != null ? (UserData.Level >= Ach.Levels.Count) : false); // Set 100% completed(??)
base.WriteString(Ach.Category);
base.WriteString("basejump");
base.WriteInteger(0); // total levels
base.WriteInteger(0);
}
base.WriteString("");
}
示例5: CardPairGame
protected CardPairGame(string name, Player player, ICollection<PictureWordPair> pairs)
: base(name, player)
{
PictureCards = pairs.Randomize().Select(x => new PictureCard(x, this) {State = DefaultCardState}).ToList();
WordCards = pairs.Randomize().Select(x => new WordCard(x, this) {State = DefaultCardState}).ToList();
UnsolvedPairs = pairs.ToList();
}
示例6: Form2
public Form2(ICollection<UserEventInfo> deltakere, EventResultHandler handler)
{
_eventResultHandler = handler;
InitializeComponent();
this._deltakere = deltakere;
var bindingList = new BindingList<UserEventInfo>(deltakere.ToList());
var source = new BindingSource(bindingList,null);
dataGridView1.DataSource = source;
dataGridView1.ReadOnly = false;
if (deltakere.First() != null)
{
//var x = new MockedEventService();
//textBox1.Text = x.GetEvents("adsf", 2016).ToList().FirstOrDefault().Id1.ToString();
//List<Event> eventer = eventService.GetEvents("adsf", DateTime.Now.Year).ToList();
var eventer = _eventResultHandler.GetEvents(new DateTime(2015, 5, 10), new DateTime(2015, 10, 31)); //DateTime.Now
if (eventer.Count > 0)
{
label2.Text = $"ID={eventer.First().Id}";
listBox1.Items.Clear();
listBox1.DataSource = eventer;
listBox1.DisplayMember = "DisplayName";
listBox1.ValueMember = "Id";
}
else
{
label2.Text = "Velg event...";
listBox1.Items.Clear();
listBox1.DataSource = eventer;
listBox1.DisplayMember = "DisplayName";
listBox1.ValueMember = "Id";
}
}
}
示例7: CFG
// create a context free grammar object with some starting symbol and sets of terminals and nonterminals
public CFG(Nonterminal start, ICollection<Terminal> terminals, ICollection<Nonterminal> nonterminals)
{
this.startSymbol = start;
this.terminals = terminals.ToList();
this.terminals.Add(Terminal.EOF);
this.nonterminals = nonterminals;
}
示例8: AreEqual
private static void AreEqual(ICollection<ProtoXamlNode> expectedStates, ICollection<ProtoXamlNode> actualStates)
{
CollectionAssert.AreEqual(
expectedStates.ToList(),
actualStates.ToList(),
new ProtoXamlNodeComparer { CheckNameOnlyForXamlTypes = false });
}
示例9: AreEqualWithLooseXamlTypeComparison
public static void AreEqualWithLooseXamlTypeComparison(ICollection<ProtoXamlNode> expectedStates, ICollection<ProtoXamlNode> actualStates)
{
CollectionAssert.AreEqual(
expectedStates.ToList(),
actualStates.ToList(),
new ProtoXamlNodeComparer { CheckNameOnlyForXamlTypes = true });
}
示例10: BuddyListComposer
public BuddyListComposer(ICollection<MessengerBuddy> Friends, Habbo Player)
: base(ServerPacketHeader.BuddyListMessageComposer)
{
base.WriteInteger(1);
base.WriteInteger(0);
base.WriteInteger(Friends.Count);
foreach (MessengerBuddy Friend in Friends.ToList())
{
Relationship Relationship = Player.Relationships.FirstOrDefault(x => x.Value.UserId == Convert.ToInt32(Friend.UserId)).Value;
base.WriteInteger(Friend.Id);
base.WriteString(Friend.mUsername);
base.WriteInteger(1);//Gender.
base.WriteBoolean(Friend.IsOnline);
base.WriteBoolean(Friend.IsOnline && Friend.InRoom);
base.WriteString(Friend.IsOnline ? Friend.mLook : string.Empty);
base.WriteInteger(0); // category id
base.WriteString(Friend.IsOnline ? Friend.mMotto : string.Empty);
base.WriteString(string.Empty);//Alternative name?
base.WriteString(string.Empty);
base.WriteBoolean(true);
base.WriteBoolean(false);
base.WriteBoolean(false);//Pocket Habbo user.
base.WriteShort(Relationship == null ? 0 : Relationship.Type);
}
}
示例11: Game2WeeklyLeaderboardComposer
public Game2WeeklyLeaderboardComposer(GameData GameData, ICollection<Habbo> Habbos)
: base(ServerPacketHeader.Game2WeeklyLeaderboardMessageComposer)
{
base.WriteInteger(2014);
base.WriteInteger(41);
base.WriteInteger(0);
base.WriteInteger(1);
base.WriteInteger(1581);
//Used to generate the ranking numbers.
int num = 0;
base.WriteInteger(Habbos.Count);//Count
foreach (Habbo Habbo in Habbos.ToList())
{
num++;
base.WriteInteger(Habbo.Id);//Id
base.WriteInteger(Habbo.FastfoodScore);//Score
base.WriteInteger(num);//Rank
base.WriteString(Habbo.Username);//Username
base.WriteString(Habbo.Look);//Figure
base.WriteString(Habbo.Gender.ToLower());//Gender .ToLower()
}
base.WriteInteger(0);//
base.WriteInteger(GameData.GameId);//Game Id?
}
示例12: AreEssentiallyTheSame
public static void AreEssentiallyTheSame(ICollection<XamlInstruction> expectedInstructions, ICollection<XamlInstruction> actualNodes)
{
CollectionAssert.AreEqual(
expectedInstructions.ToList(),
actualNodes.ToList(),
new XamlNodeComparer { CheckNameOnlyForXamlTypes = true });
}
示例13: UserUpdateComposer
public UserUpdateComposer(ICollection<RoomUser> RoomUsers)
: base(ServerPacketHeader.UserUpdateMessageComposer)
{
base.WriteInteger(RoomUsers.Count);
foreach (RoomUser User in RoomUsers.ToList())
{
base.WriteInteger(User.VirtualId);
base.WriteInteger(User.X);
base.WriteInteger(User.Y);
base.WriteString(User.Z.ToString("0.00"));
base.WriteInteger(User.RotHead);
base.WriteInteger(User.RotBody);
StringBuilder StatusComposer = new StringBuilder();
StatusComposer.Append("/");
foreach (KeyValuePair<string, string> Status in User.Statusses.ToList())
{
StatusComposer.Append(Status.Key);
if (!String.IsNullOrEmpty(Status.Value))
{
StatusComposer.Append(" ");
StatusComposer.Append(Status.Value);
}
StatusComposer.Append("/");
}
StatusComposer.Append("/");
base.WriteString(StatusComposer.ToString());
}
}
示例14: RoleIndexModel
public RoleIndexModel(ICollection<Role> roles, int? index)
{
this.Roles = roles.ToList();
if (index != null && index.HasValue && this.Roles != null && index.Value < this.Roles.Count)
this.Current = this[index.Value];
else
this.Current = this.Roles.FirstOrDefault();
}
示例15: AppendEventsToStream
public void AppendEventsToStream(string id, long expectedVersion, ICollection<IEvent> events)
{
foreach (var @event in events)
{
Log.Info("{0}", @event);
}
_store.AddOrUpdate(id, events.ToList(), (s, list) => list.Concat(events).ToList());
}