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


C# IList.Union方法代码示例

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


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

示例1: InsertAll

        public IObservable<Unit> InsertAll(IList<Session> sessions)
        {
            return blob.GetOrCreateObject<IList<Session>>(KEY_SESSIONS, () => new List<Session>())
                .Select(source =>
                    {
                        var checkedSessions = sessions.Where(session => session.IsChecked).ToDictionary(session => session.id);
                        var merged = sessions.Union(source);

                        return merged.Select(session =>
                            {
                                session.IsChecked = checkedSessions.ContainsKey(session.id);
                                return session;
                            });
                    })
                .SelectMany(merged =>
                    {
                        return Observable.Merge(
                            merged.ToObservable()
                                .Select(session => session.category)
                                .ToList().Distinct()
                                .SelectMany(categoryDao.InsertAll),
                            merged.ToObservable()
                                .Select(session => session.place)
                                .ToList().Distinct()
                                .SelectMany(placeDao.InsertAll),
                            blob.InsertObject(KEY_SESSIONS, merged)
                        );
                    });
        }
开发者ID:amay077,项目名称:DroidKaigi2016Xamarin,代码行数:29,代码来源:SessionDao.cs

示例2: InitialiseProfiles

 /// <summary>
 /// Initialises the list of profiles
 /// </summary>
 private void InitialiseProfiles()
 {
     _existingProfiles = _authService.GetProfiles();
     foreach (var i in _existingProfiles.Union(new[] { NewProfileItem }))
     {
         cbbProfiles.Items.Add(i);
     }
     cbbProfiles.SelectedIndex = 0;
 }
开发者ID:erdincay,项目名称:CoinTNet,代码行数:12,代码来源:LoginForm.cs

示例3: InsertAll

 public IObservable<Unit> InsertAll(IList<Category> categories)
 {
     return blob.GetOrCreateObject<IList<Category>>(KEY_CATEGORIES, () => new List<Category>())
         .Select(source =>
             {
                 return categories.Union(source);
             })
         .SelectMany(merged => blob.InsertObject(KEY_CATEGORIES, merged));
 }
开发者ID:amay077,项目名称:DroidKaigi2016Xamarin,代码行数:9,代码来源:CategoryDao.cs

示例4: Subscribe

        public void Subscribe(string client, IList<string> messageTypes)
        {
            using (var session = _sessionFactory.OpenSession())
            {
                var existingSubscription = session.AsQueryable<Subscription>().SingleOrDefault(x => x.SubscriberEndpoint == client) 
                    ?? new Subscription { SubscriberEndpoint = client, MessageTypes = new List<string>() };

                var messageTypesToSubscribe = messageTypes.Union(existingSubscription.MessageTypes).ToList();

                existingSubscription.MessageTypes = messageTypesToSubscribe;
                session.Store(existingSubscription);
                session.Commit();
            }
        }
开发者ID:jhicks,项目名称:NServiceBus.Db4o,代码行数:14,代码来源:Db4oSubscriptionStorage.cs

示例5: Serialize

 public byte[] Serialize(IList<HeaderInfo> headers)
 {
   if (CurrentSagaIds.OutgoingIds != null && CurrentSagaIds.OutgoingIds.Length > 0)
   {
     var value = String.Join(",", CurrentSagaIds.OutgoingIds.Select(x => x.ToString()).ToArray());
     var header = new HeaderInfo()
     {
       Key = "machine.sagas",
       Value = value
     };
     _log.Debug("Serializing: " + value);
     return _serializer.Serialize(headers.Union(new[] { header }).ToList());
   }
   return _serializer.Serialize(headers);
 }
开发者ID:machine,项目名称:machine.mta,代码行数:15,代码来源:MtaCompatibilityHeadersSerializer.cs

示例6: Page_Init

    protected void Page_Init(object sender, EventArgs e)
    {
        #region 設定搜尋控制項目

        plSearch.Controls.Add(new LiteralControl("<br />"));

        Search_Date sd = new Search_Date(this.ViewState, plSearch, "日期範圍", "selectDate", "sCreatetime", "tbStartDate", "tbEndDate");
        SearchItems = SearchItems.Union(sd.SearchItems).ToList();
        Search_Checkbox sc = new Search_Checkbox(this.ViewState, plSearch, "僅列出有效資料", "chksFBUID", "sFBUID");
        SearchItems = SearchItems.Union(sc.SearchItems).ToList();
        st = new Search_Textfield(this.ViewState, plSearch, "sFBUID:", "tbsFBUID", "sFBUID", "sFBUID");
        SearchItems = SearchItems.Union(st.SearchItems).ToList();
        st = new Search_Textfield(this.ViewState, plSearch, "sFBDisplayName:", "tbsFBDisplayName", "sFBDisplayName", "sFBDisplayName");
        SearchItems = SearchItems.Union(st.SearchItems).ToList();
        st = new Search_Textfield(this.ViewState, plSearch, "sName:", "tbsName", "sName", "sName");
        SearchItems = SearchItems.Union(st.SearchItems).ToList();

        #endregion
    }
开发者ID:patw0929,项目名称:AspNetEventSiteDemo,代码行数:19,代码来源:List.aspx.cs

示例7: CheckForStraightFlushOfClubs

        /// <summary>
        /// This method determins if straight flush of clubs combination is available 
        /// </summary>
        /// <param name="charactersCardsCollection">
        /// Player's cards
        /// </param>
        /// <param name="tableCardsCollection">
        /// All cards visible on the table
        /// </param>
        /// <param name="character">
        /// current player
        /// </param>
        /// <returns></returns>
        private bool CheckForStraightFlushOfClubs(IList<ICard> charactersCardsCollection,
            IList<ICard> tableCardsCollection, ICharacter character)
        {
            bool hasStraightFlush = false;

            List<ICard> joinedCardCollection = charactersCardsCollection.Union(tableCardsCollection.Where(x => x.IsVisible)).ToList();

            List<ICard> straightFlushCardsCollection = joinedCardCollection.Where(c => c.Suit == CardSuit.Clubs).ToList();

            straightFlushCardsCollection = new List<ICard>(straightFlushCardsCollection.OrderByDescending(c => c.Rank));

            if (straightFlushCardsCollection.Count < 5)
            {
                return false;
            }
            else
            {
                straightFlushCardsCollection = straightFlushCardsCollection.Take(5).ToList();

                double power = 0;
                for (int i = 0; i < straightFlushCardsCollection.Count - 1; i++)
                {
                    if ((int)straightFlushCardsCollection[i].Rank - 1 != (int)straightFlushCardsCollection[i + 1].Rank)
                    {
                        return false;
                    }
                }

                if (straightFlushCardsCollection[0].Rank == CardRank.Ace)
                {
                    power = (int)straightFlushCardsCollection[0].Rank + BigStraightFlushBehaviourPower * 100;
                }

                else
                {
                    power = (int)straightFlushCardsCollection[0].Rank + LittleStraightFlushBehaviourPower * 100;
                }

                IList<ICard> theOtherCardsFromTheHandNotIncludedInTheCombination = joinedCardCollection.Where(x => !straightFlushCardsCollection.Contains(x)).ToList();

                if (character.CardsCombination == null || character.CardsCombination.Type < CombinationType.StraightFlush)
                {
                    character.CardsCombination = new Combination(
                        power,
                        CombinationType.StraightFlush,
                        LittleStraightFlushBehaviourPower,
                        straightFlushCardsCollection,
                        theOtherCardsFromTheHandNotIncludedInTheCombination);
                }

                hasStraightFlush = true;
            }

            return hasStraightFlush;
        }
开发者ID:john6tain,项目名称:Poker-Mechanics,代码行数:68,代码来源:Dealer.cs

示例8: CheckForTwoPairs

        /// <summary>
        /// Checks if the character has two pairs.
        /// </summary>
        /// <param name="charactersCardsCollection"></param>
        /// <param name="tableCardsCollection"></param>
        /// <param name="character"></param>
        /// <returns></returns>
        private bool CheckForTwoPairs(IList<ICard> charactersCardsCollection,
        IList<ICard> tableCardsCollection, ICharacter character)
        {
            bool hasOnePair = CheckForOnePair(charactersCardsCollection, tableCardsCollection, character, false);

            bool hasASecondPair = false;

            if (hasOnePair)
            {
                IList<ICard> nonCombinationCards = charactersCardsCollection.Union(tableCardsCollection).Where(x => !character.CardsCombination.CombinationCardsCollection.Contains(x) && x.IsVisible).ToList();

                IList<ICard> emptyCollection = new List<ICard>();

                hasASecondPair = CheckForOnePair(nonCombinationCards, emptyCollection, character, true);
            }
            return hasASecondPair;
        }
开发者ID:john6tain,项目名称:Poker-Mechanics,代码行数:24,代码来源:Dealer.cs

示例9: CheckForOnePair

        /// <summary>
        /// Checks if the two character's cards make a "Pair" or if one of the character's cards makes a "Pair" with one card from the table.
        /// </summary>
        /// <param name="charactersCardsCollection"></param>
        /// <param name="tableCardsCollection"></param>
        /// <param name="character"></param>
        /// <returns></returns>
        private bool CheckForOnePair(IList<ICard> charactersCardsCollection, IList<ICard> tableCardsCollection, ICharacter character, bool isCheckingForASecondPair)
        {
            IList<ICombination> combinationsCollection = new List<ICombination>();

            bool foundOnePair = false;
            bool foundASecondPair = false;

            IList<ICard> joinedCardCollection = charactersCardsCollection.Union(tableCardsCollection.Where(x => x.IsVisible)).ToList();

            FindAllOnePairCombinations(joinedCardCollection, combinationsCollection);

            combinationsCollection = combinationsCollection.OrderByDescending(x => x.Power).ToList();

            if (isCheckingForASecondPair)
            {
                if (combinationsCollection.Count >= 1)
                {
                    foundASecondPair = true;
                }

                if (foundASecondPair)
                {
                    RegisterTwoPairs(character, combinationsCollection);
                }
            }
            else
            {
                if (combinationsCollection.Count >= 1)
                {
                    foundOnePair = true;
                    RegisterOnePair(character, combinationsCollection);
                }
            }

            bool foundAPairOrPairs = foundOnePair || foundASecondPair;

            return foundAPairOrPairs;
        }
开发者ID:john6tain,项目名称:Poker-Mechanics,代码行数:45,代码来源:Dealer.cs

示例10: CheckForHighCard

        /// <summary>
        /// Checks for a "High card" combination
        /// </summary>
        /// <param name="charactersCardsCollection"></param>
        /// <param name="tableCardsCollection"></param>
        /// <param name="character"></param>
        /// <returns></returns>
        private bool CheckForHighCard(IList<ICard> charactersCardsCollection, IList<ICard> tableCardsCollection, ICharacter character)
        {
            double power = Math.Max((double)charactersCardsCollection[0].Rank, (double)charactersCardsCollection[1].Rank);

            IList<ICard> joinedCardCollection = charactersCardsCollection.Union(tableCardsCollection.Where(x => x.IsVisible)).OrderByDescending(x => x.Rank).ToList();

            IList<ICard> combinationCardsCollection = new List<ICard>();
            combinationCardsCollection.Add(joinedCardCollection[0]);

            IList<ICard> nonCombinationCards = joinedCardCollection.Where(x => !combinationCardsCollection.Contains(x)).ToList();

            RegisterCombination(character, power, combinationCardsCollection, nonCombinationCards, CombinationType.HighCard, Constants.HighCardBehaviourPower);

            return true;
        }
开发者ID:john6tain,项目名称:Poker-Mechanics,代码行数:22,代码来源:Dealer.cs

示例11: GetThreeOfAKindCardRank

        //This method gets the rank (number) of the cards that make up a three-of-a-kind
        private int GetThreeOfAKindCardRank(IList<ICard> charactersCardsCollection, IList<ICard> tableCardsCollection)
        {
            int cardRank = -1;

            IList<ICard> joinedCardCollection =
                charactersCardsCollection.Union(tableCardsCollection.Where(x => x.IsVisible)).ToList();

            foreach (var element in joinedCardCollection)
            {
                IList<ICard> sameRankCardsCollection = joinedCardCollection.Where(x => x.Rank == element.Rank).ToList();

                if (sameRankCardsCollection.Count == 3)
                {
                    cardRank = (int)element.Rank;
                }
            }

            return cardRank;
        }
开发者ID:john6tain,项目名称:Poker-Mechanics,代码行数:20,代码来源:Dealer.cs

示例12: CheckForFullHouse

        /// <summary>
        /// This method checks if the character has card combination "Full House"
        /// </summary>
        /// <param name="charactersCardsCollection">The collection of cards in the characters hand.</param>
        /// <param name="tableCardsCollection">The collection of cards on the table.</param>
        /// <param name="character">The character that holds the cards.</param>
        /// <returns><c>true</c> if the character has a Full House, <c>false</c> if they don't.</returns>
        private bool CheckForFullHouse(IList<ICard> charactersCardsCollection, IList<ICard> tableCardsCollection,
            ICharacter character)
        {
            bool hasFullHouse = false;

            IList<ICard> joinedCardCollection = charactersCardsCollection.Union(tableCardsCollection.Where(x => x.IsVisible)).ToList();

            bool characterHasThreeOfAKind = CheckForThreeOfAKind(charactersCardsCollection, tableCardsCollection,
                character);

            IList<ICard> threeOfAKindCards = new List<ICard>();

            int threeOfAKindRank = -1;

            if (characterHasThreeOfAKind)
            {
                threeOfAKindRank = GetThreeOfAKindCardRank(charactersCardsCollection, tableCardsCollection);

                //removes the three-of-a-kind cards from the joinedCardCollection (hand+table cards)
                // and adds them to the threeOfAKindCards list
                for (int i = 0; i < joinedCardCollection.Count; i++)
                {
                    if ((int)joinedCardCollection[i].Rank == threeOfAKindRank)
                    {
                        threeOfAKindCards.Add(joinedCardCollection[i]);
                        joinedCardCollection.RemoveAt(i);
                        i--;
                    }
                }

                //checks if there is a pair in the remaining collection
                //if yes -> the player has a full house combination
                int maxPairRank = -1;
                foreach (ICard card in joinedCardCollection)
                {
                    IList<ICard> remainingEqualRankCards =
                        joinedCardCollection.Where(x => x.Rank == card.Rank).ToList();

                    if (remainingEqualRankCards.Count == 2)
                    {
                        hasFullHouse = true;

                        //This is a check for multiple pairs in the remaining cards
                        //If there is more than one pair, the highest one is taken
                        maxPairRank = Math.Max(maxPairRank, (int)card.Rank); //  take the one with the higher rank

                        IList<ICard> theOtherCardsFromTheHandNotIncludedInTheCombination =
                            joinedCardCollection.Where(x => x != remainingEqualRankCards[0]).ToList();

                        IList<ICard> fullHouseCards = threeOfAKindCards;
                        fullHouseCards = fullHouseCards.Union(remainingEqualRankCards).ToList();


                        double power = maxPairRank * 2 + FullHouseBehaviourPower * 100;

                        if (character.CardsCombination == null ||
                            character.CardsCombination.Type < CombinationType.FullHouse)
                        {
                            character.CardsCombination = new Combination(power, CombinationType.FullHouse, Constants.FullHouseBehaviourPower, fullHouseCards, theOtherCardsFromTheHandNotIncludedInTheCombination);
                        }

                    }
                }
            }

            return hasFullHouse;
        }
开发者ID:john6tain,项目名称:Poker-Mechanics,代码行数:74,代码来源:Dealer.cs

示例13: UpdateAll

 public IObservable<Unit> UpdateAll(IList<Session> sessions)
 {
     return blob.GetOrCreateObject<IList<Session>>(KEY_SESSIONS, () => new List<Session>())
         .Select(source =>
             {
                 return sessions.Union(source);
             })
         .SelectMany(merged => blob.InsertObject(KEY_SESSIONS, merged));
 }
开发者ID:nepula-h-okuyama,项目名称:DroidKaigi2016Xamarin,代码行数:9,代码来源:SessionDao.cs

示例14: FindTypesInBounds

        IList<IType> FindTypesInBounds(IList<IType> lowerBounds, IList<IType> upperBounds)
        {
            // If there's only a single type; return that single type.
            // If both inputs are empty, return the empty list.
            if (lowerBounds.Count == 0 && upperBounds.Count <= 1)
                return upperBounds;
            if (upperBounds.Count == 0 && lowerBounds.Count <= 1)
                return lowerBounds;
            if (nestingLevel > maxNestingLevel)
                return EmptyList<IType>.Instance;

            // Finds a type X so that "LB <: X <: UB"
            Log.WriteCollection("FindTypesInBound, LowerBounds=", lowerBounds);
            Log.WriteCollection("FindTypesInBound, UpperBounds=", upperBounds);

            // First try the Fixing algorithm from the C# spec (§7.5.2.11)
            List<IType> candidateTypes = lowerBounds.Union(upperBounds)
                .Where(c => lowerBounds.All(b => conversions.ImplicitConversion(b, c).IsValid))
                .Where(c => upperBounds.All(b => conversions.ImplicitConversion(c, b).IsValid))
                .ToList(); // evaluate the query only once

            Log.WriteCollection("FindTypesInBound, Candidates=", candidateTypes);

            // According to the C# specification, we need to pick the most specific
            // of the candidate types. (the type which has conversions to all others)
            // However, csc actually seems to choose the least specific.
            candidateTypes = candidateTypes.Where(
                c => candidateTypes.All(o => conversions.ImplicitConversion(o, c).IsValid)
            ).ToList();

            // If the specified algorithm produces a single candidate, we return
            // that candidate.
            // We also return the whole candidate list if we're not using the improved
            // algorithm.
            if (candidateTypes.Count == 1 || !(algorithm == TypeInferenceAlgorithm.Improved || algorithm == TypeInferenceAlgorithm.ImprovedReturnAllResults))
            {
                return candidateTypes;
            }
            candidateTypes.Clear();

            // Now try the improved algorithm
            Log.Indent();
            List<ITypeDefinition> candidateTypeDefinitions;
            if (lowerBounds.Count > 0) {
                // Find candidates by using the lower bounds:
                var hashSet = new HashSet<ITypeDefinition>(lowerBounds[0].GetAllBaseTypeDefinitions());
                for (int i = 1; i < lowerBounds.Count; i++) {
                    hashSet.IntersectWith(lowerBounds[i].GetAllBaseTypeDefinitions());
                }
                candidateTypeDefinitions = hashSet.ToList();
            } else {
                // Find candidates by looking at all classes in the project:
                candidateTypeDefinitions = compilation.GetAllTypeDefinitions().ToList();
            }

            // Now filter out candidates that violate the upper bounds:
            foreach (IType ub in upperBounds) {
                ITypeDefinition ubDef = ub.GetDefinition();
                if (ubDef != null) {
                    candidateTypeDefinitions.RemoveAll(c => !c.IsDerivedFrom(ubDef));
                }
            }

            foreach (ITypeDefinition candidateDef in candidateTypeDefinitions) {
                // determine the type parameters for the candidate:
                IType candidate;
                if (candidateDef.TypeParameterCount == 0) {
                    candidate = candidateDef;
                } else {
                    Log.WriteLine("Inferring arguments for candidate type definition: " + candidateDef);
                    bool success;
                    IType[] result = InferTypeArgumentsFromBounds(
                        candidateDef.TypeParameters,
                        new ParameterizedType(candidateDef, candidateDef.TypeParameters),
                        lowerBounds, upperBounds,
                        out success);
                    if (success) {
                        candidate = new ParameterizedType(candidateDef, result);
                    } else {
                        Log.WriteLine("Inference failed; ignoring candidate");
                        continue;
                    }
                }
                Log.WriteLine("Candidate type: " + candidate);

                if (upperBounds.Count == 0) {
                    // if there were only lower bounds, we aim for the most specific candidate:

                    // if this candidate isn't made redundant by an existing, more specific candidate:
                    if (!candidateTypes.Any(c => c.GetDefinition().IsDerivedFrom(candidateDef))) {
                        // remove all existing candidates made redundant by this candidate:
                        candidateTypes.RemoveAll(c => candidateDef.IsDerivedFrom(c.GetDefinition()));
                        // add new candidate
                        candidateTypes.Add(candidate);
                    }
                } else {
                    // if there were upper bounds, we aim for the least specific candidate:

                    // if this candidate isn't made redundant by an existing, less specific candidate:
                    if (!candidateTypes.Any(c => candidateDef.IsDerivedFrom(c.GetDefinition()))) {
//.........这里部分代码省略.........
开发者ID:svermeulen,项目名称:NRefactory,代码行数:101,代码来源:TypeInference.cs

示例15: SaveToCache

        public void SaveToCache(IList<ITweetable> viewport)
        {
            if (!Cached)
                return;

            var toSave = viewport
                .Union(Source.OrderByDescending(x => x.Id).Take(CacheSize))
                .OfType<TwitterStatus>()
                .OrderByDescending(x => x.Id);

            try
            {
                Cacher.SaveToCache(Resource, toSave);
            }
            catch (Exception)
            {
            }
        }
开发者ID:Quertz,项目名称:Ocell,代码行数:18,代码来源:TweetLoader.cs


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