예제 #1
0
 private Spell CheckForDuplicates(string reqSpellName)
 {
     System.Collections.Generic.IEnumerable <Spell> spellQuery = effectList.Where(spell => spell.spellName == reqSpellName);
     if (spellQuery.Count() > 0)
     {
         return(spellQuery.First());
     }
     return(null);
 }
예제 #2
0
        /// <summary>
        /// Gets items contained in all colletions.
        /// </summary>
        public static HashSet <T> GetCommonItems <T>(IEnumerable <IEnumerable <T> > lists)
        {
            if (lists?.Any() != true || lists?.First()?.Any() != true)
            {
                return(new HashSet <T>());
            }

            var set = new HashSet <T>(lists.First());

            foreach (var list in lists)
            {
                if (list != null)
                {
                    set.IntersectWith(list);
                }
            }

            return(set);
        }