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


C# ICollection.Count方法代码示例

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


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

示例1: Add

        public JsonResult Add(int encounterId, ICollection<int> newTurnOrder, string description)
        {
            // This is because the LINQ can't translate this command, it needs a flat int.
            var actorId = newTurnOrder.First();

            var encounter = context.Encounters.First(e => e.Id.Equals(encounterId));
            var actingCharacter = context.Characters.First(p => p.Id.Equals(actorId));

            var feedEntry = new EncounterFeedEntry
            {
                ActingCharacter = actingCharacter,
                Description = description
            };
            context.Actions.Add(feedEntry);

            encounter.Initiatives.First(p => p.Character.Id.Equals(newTurnOrder.ElementAt(0)))
                .TurnOrder = newTurnOrder.Count()-1;

            for(var i=1; i<newTurnOrder.Count(); ++i)
            {
                encounter.Initiatives.First(p => p.Character.Id.Equals(newTurnOrder.ElementAt(i)))
                    .TurnOrder = i-1;
            }

            encounter.FeedEntries.Add(feedEntry);
            context.SaveChanges();

            return Json("Successfully posted");
        }
开发者ID:etkirsch,项目名称:The-DM-Screen,代码行数:29,代码来源:FeedEntryController.cs

示例2: recommend

 public ICollection<Film> recommend(ICollection<Film> precondition, ICollection<Film> yetRecommended, int Number)
 {
     if(precondition==null|| precondition.Count<1)
         return new List<Film>();
     var retList = new List<Film>();
     for (int i = 0; i < (Number>0?Number:10); i++)
     {
         var tmp_film = precondition.ElementAt(new Random().Next(0, precondition.Count()-1));
         if(tmp_film.actors!=null&&tmp_film.actors.Count()>0)
         {
             var tmp_actor = tmp_film.actors.ElementAt(new Random().Next(0, tmp_film.actors.Count()-1));
             if (tmp_actor != null)
             {
                 tmp_actor = actorsservice.getActorWithFilmsFromDAL(tmp_actor.ID);
                 if (tmp_actor != null&&tmp_actor.films.Count()>0)
                 {
                     var rec_film = tmp_actor.films.ElementAt(new Random().Next(0, tmp_actor.films.Count() - 1));
                     if (!yetRecommended.Contains(rec_film) && !retList.Contains(rec_film))
                         retList.Add(rec_film);
                 }
             }
         }
     }
     return retList;
 }
开发者ID:tscherkas,项目名称:filmsWebApp,代码行数:25,代码来源:MyFilmRecommendService.cs

示例3: PointAndSuitCountParameter

 private float PointAndSuitCountParameter(Card card, PlayerTurnContext context, ICollection<Card> allowedCards)
 {
     var cardSuit = card.Suit;
     float cardValue = card.GetValue();
     float coutOfSuitInHand = allowedCards.Count(x => x.Suit == cardSuit);
     return (11f - cardValue) * coutOfSuitInHand;
 }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:7,代码来源:CardEvaluatorFirstPlayer.cs

示例4: RedisLock

		public RedisLock(
			ICollection<ConnectionMultiplexer> redisCaches,
			string resource,
			TimeSpan expiryTime,
			TimeSpan? waitTime = null,
			TimeSpan? retryTime = null,
			Func<string, string> redisKeyFormatter = null,
			IRedLockLogger logger = null)
		{
			this.redisCaches = redisCaches;
			var formatter = redisKeyFormatter ?? DefaultRedisKeyFormatter;
			this.logger = logger ?? new NullLogger();

			quorum = redisCaches.Count() / 2 + 1;
			quorumRetryCount = 3;
			quorumRetryDelayMs = 400;
			clockDriftFactor = 0.01;
			redisKey = formatter(resource);

			Resource = resource;
			LockId = Guid.NewGuid().ToString();
			this.expiryTime = expiryTime;
			this.waitTime = waitTime;
			this.retryTime = retryTime;

			Start();
		}
开发者ID:rosslynquynhnguyen,项目名称:RedLock.net,代码行数:27,代码来源:RedisLock.cs

示例5: Insert

 public static int Insert(this Collection<Instruction> collection, int index, ICollection<Instruction> instructions)
 {
     foreach (var instruction in instructions.Reverse())
     {
         collection.Insert(index, instruction);
     }
     return index + instructions.Count();
 }
开发者ID:mdabbagh88,项目名称:NullGuard,代码行数:8,代码来源:InstructionListExtensions.cs

示例6: IsRuleMet

        public bool IsRuleMet(ICollection<string> data, ICollection<string> criteriaData)
        {
            if (data.Count() != 1 && criteriaData.Count() != 1)
            {
                return !criteriaData.Except(data).Any();
            }

            return data.First().Contains(criteriaData.First());
        }
开发者ID:CruelMoney,项目名称:AutoSys,代码行数:9,代码来源:RuleCheckers.cs

示例7: CheckPageExercises

        private static void CheckPageExercises(ExercisePage page, ICollection<Exercise> expectedExercises)
        {
            foreach (var expectedExercise in expectedExercises)
            {
                Assert.That(page.IsShowing(expectedExercise), string.Format("exercise {0} was not on page", expectedExercise.Name));
            }

            Assert.That(page.ExerciseCount, Is.EqualTo(expectedExercises.Count()));
        }
开发者ID:JWroe,项目名称:HEWFitness,代码行数:9,代码来源:ExercisePageSmokeTests.cs

示例8: HasBookToReturn

        private async Task HasBookToReturn(ICollection<Loan> books)
        {
            if (books.Count() == 0)
            {
                Console.WriteLine(Display.NotBooksToReturn);
                return;
            }

            await ShowNotReturningBook(books);
        }
开发者ID:SogetiSpain,项目名称:code-challenge-3,代码行数:10,代码来源:ReturnBook.cs

示例9: SetCheckState

        private void SetCheckState(int visgroupId, ICollection<MapObject> visItems)
        {
            var numHidden = visItems.Count(x => x.IsVisgroupHidden);

            CheckState state;
            if (numHidden == visItems.Count) state = CheckState.Unchecked; // All hidden
            else if (numHidden > 0) state = CheckState.Indeterminate; // Some hidden
            else state = CheckState.Checked; // None hidden

            VisgroupPanel.SetCheckState(visgroupId, state);
        }
开发者ID:silky,项目名称:sledge,代码行数:11,代码来源:VisgroupSidebarPanel.cs

示例10: AddRandomPaths

        private void AddRandomPaths(ICollection<Location> locations)
        {
            var rnd = new Random();

            locations.ForEach(location =>
            {
                for (int i = 0; i < rnd.Next(0, 3); i++)
                {
                    location.ConnectedLocations.Add(locations.ElementAt(rnd.Next(0, locations.Count())));
                }
            });
        }
开发者ID:UnderNotic,项目名称:ShortPathAlg,代码行数:12,代码来源:RandomGraphGenerator.cs

示例11: WriteAssemblyAttributesInternal

		public virtual void WriteAssemblyAttributesInternal(AssemblyDefinition assembly, ICollection<string> assemblyNamespaceUsings,
			ICollection<string> mainModuleNamespaceUsings, bool writeUsings = false, ICollection<string> attributesToIgnore = null)
		{
			if (writeUsings && (assemblyNamespaceUsings.Count() > 0 || mainModuleNamespaceUsings.Count() > 0))
			{
				Writer.WriteAssemblyUsings();
				Writer.WriteLine();
				Writer.WriteLine();
			}

			AttributeWriter.WriteAssemblyAttributes(assembly, attributesToIgnore);
		}
开发者ID:juancarlosbaezpozos,项目名称:JustDecompileEngine,代码行数:12,代码来源:BaseAssemblyAttributeWriter.cs

示例12: GetBestSynonym

 public static WordModel GetBestSynonym(WordModel word, ICollection<WordModel> synonyms, WordTrait desired = null)
 {
     if (!synonyms.Any())
     {
         return word;
     }
     if (synonyms.Count() == 1)
     {
         return synonyms.First();
     }
     return BestSynonymMatchByTrait(synonyms, desired);
 }
开发者ID:samdamana,项目名称:Smartifyer,代码行数:12,代码来源:SynonymLogicService.cs

示例13: ValidateStrategy

        private void ValidateStrategy(ICollection<IPlayer> players, IBoard board)
        {
            if (players.Count() != GlobalConstants.StandartGameNumberOfPlayers)
            {
                throw new InvalidOperationException("Standart Play Game Initialization Strategy needs exactly two players!");
            }

            if (board.TotalRows != GlobalConstants.StandartGameTotalBoardRows ||
                board.TotalCols != GlobalConstants.StandartGameTotalBoardCols)
            {
                throw new InvalidOperationException("Standart Play Game Initialization Strategy needs 8x8 board!");
            }
        }
开发者ID:King-Survival-3,项目名称:HQC-Teamwork-2015,代码行数:13,代码来源:StandartStartGameInitializationStrategy.cs

示例14: AppendToStore

 public void AppendToStore(string name, ICollection<MessageAttribute> attribs, long streamVersion, ICollection<object> messages)
 {
     using (var mem = new MemoryStream())
     {
         _serializer.WriteAttributes(attribs, mem);
         _serializer.WriteCompactInt(messages.Count(), mem);
         foreach (var message in messages)
         {
             _serializer.WriteMessage(message, message.GetType(), mem);
         }
         _appendOnlyStore.Append(name, mem.ToArray(), streamVersion);
     }
 }
开发者ID:11646729,项目名称:iSeismic,代码行数:13,代码来源:MessageStore.cs

示例15: ServerBatchRefresher

        public ServerBatchRefresher(string inProgressText, ICollection<Server> items, ICollection<Server> _oldItems = null)
        {
            _items = items;
            _removedItems = new List<Server>();
            if (_oldItems != null)
            {
                foreach (Server item in _oldItems)
                {
                    if (_items.Count(x => x.Id.Equals(item.Id)) < 1) //this server has been removed
                        _removedItems.Add(item);
                }
            }

            InProgressText = inProgressText;
        }
开发者ID:rajkosto,项目名称:DayZeroLauncher,代码行数:15,代码来源:ServerBatchRefresher.cs


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