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


C# List.Contains方法代码示例

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


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

示例1: GetFarFromOneRelations

        public static List<UserProfile> GetFarFromOneRelations(Guid userId)
        {
            // On cherche nos relations. On cherche les relations de nos relations => récursif
            List<UserProfile> listUserRelations = GetRelations(userId);

            List<UserProfile> listLoggedUserRelation = GetRelations((Guid)(Membership.GetUser(System.Web.HttpContext.Current.User.Identity.Name, false).ProviderUserKey));

            List<UserProfile> listFarFromOneRelations = new List<UserProfile>();

            // We search all the directly connected users to the actual logged user relations
            foreach (UserProfile userRelation in listUserRelations)
            {
                listFarFromOneRelations.AddRange(GetRelations((Guid)(Membership.GetUser(userRelation.UserName, false).ProviderUserKey)));
            }

            UserProfile actualUser = UserProfile.GetUserProfile(System.Web.HttpContext.Current.User.Identity.Name);
            while(listFarFromOneRelations.Contains(actualUser))
            {
                // We delete all the occurences of the actual user
                listFarFromOneRelations.Remove(actualUser);
            }

            // On supprime les utilisateurs qui sont déjà directement connectés avec l'utilisateur
            foreach (UserProfile user in listLoggedUserRelation)
            {
                if (listFarFromOneRelations.Contains(user))
                {
                    listFarFromOneRelations.Remove(user);
                }
            }

            return listFarFromOneRelations;
        }
开发者ID:remimarenco,项目名称:BindedIn,代码行数:33,代码来源:RelationService.cs

示例2: MergeFiles

        public static void MergeFiles(Repository repo)
        {
            var f1 = repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.UniqueEmailAddressesFilename;
            var f2 = repo.StorageWrapper.Data.MineableDataDirectory + Extractor.LinkedInFilename;
            var f3 = repo.StorageWrapper.Data.MineableDataDirectory + Extractor.IgnoreListFilename;

            if (!File.Exists(f1))
            {
                Console.WriteLine("Unable to locate " + f1);
                return;
            }

            if (!File.Exists(f2))
            {
                Console.WriteLine("Unable to locate " + f2);
                return;
            }

            if (!File.Exists(f3))
            {
                Console.WriteLine("Unable to locate " + f3);
                return;
            }

            var mozilla = File.ReadLines(f1).ToList();
            var linkedIn = File.ReadLines(f2).ToList();
            var ignore = File.ReadLines(f3).ToList();
            var final = new List<string>();

            foreach (var line in mozilla.Where(line => !final.Contains(line.ToLower())).Where(line => ignore.All(ignorePart => !line.ToLower().Contains(ignorePart.ToLower()))))
            {
                final.Add(line.ToLower());
            }
            foreach (var line in linkedIn.Where(line => !final.Contains(line.ToLower())).Where(line => ignore.All(ignorePart => !line.ToLower().Contains(ignorePart.ToLower()))))
            {
                final.Add(line.ToLower());
            }

            final.Sort();

            File.WriteAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename, final);

            var domains = final.Where(x => x.Contains('@')).Select(x => x.Split('@')[1]).Distinct().ToList();

            domains.Sort();

            File.WriteAllLines(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.UniqueDomainsFilename, domains);

            if (UIRetriever.GetBool(String.Format("View {0}?", Extractor.ConvergedEmailAddressesFilename)))
            {
                FileVisualiser.Show(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename);
            }

            if (UIRetriever.GetBool(String.Format("View {0}?", repo.StorageWrapper.Data.MineableDataResultsDirectory)))
            {
                DirectoryVisualiser.ShowFile(repo.StorageWrapper.Data.MineableDataResultsDirectory + Extractor.ConvergedEmailAddressesFilename);
            }
        }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:58,代码来源:FileMerger.cs

示例3: AfterImport

        public void AfterImport(IList added, IList updated)
        {
            if (GlobalSettings.runAfterImport)
            {
                var activities = new List<IActivity>();

                foreach (object record in added)
                {
                    if (record is IActivity)
                    {
                        activities.Add(record as IActivity);
                    }
                }

                foreach (object record in updated)
                {
                    if (record is IActivity)
                    {
                        activities.Add(record as IActivity);
                    }
                }

                GlobalSettings.LoadSettings();

                if (GlobalSettings.calculateFutureAfterImport)
                {
                    DateTime oldestActivity = DateTime.MaxValue;

                    foreach (IActivity activity in activities)
                    {
                        if (activity.StartTime < oldestActivity)
                        {
                            oldestActivity = activity.StartTime;
                        }
                    }

                    foreach (IActivity activity in CalculatedFields.GetLogBook().Activities)
                    {
                        if (activity.StartTime >= oldestActivity)
                        {
                            if (!activities.Contains(activity))
                            {
                                activities.Add(activity);
                            }
                        }
                    }
                }

                Evaluator.Calculate(activities, null, false);
            }
        }
开发者ID:gerhardol,项目名称:calculatedfields,代码行数:51,代码来源:ExtendImport.cs

示例4: Cr

        public static void Cr(string name, string type, int length, string output)
        {
            List<List<int>> lists = length == 2 ? GetPr2() : GetPr3();
            List<string> clist = new List<string>(360);
            foreach (var list in lists)
            {
                Permutations<int> p = new Permutations<int>(list, length);
                List<string> pn = p.Get(",");
                if (pn.Exists(x => clist.Contains(x))) continue;

                clist.Add(list.Format(","));
            }

            if (output.Equals("txt"))
            {
                SaveToText(name, type, clist);
                return;
            }

            SaveToDB(name, type, clist);
        }
开发者ID:tomdeng,项目名称:gaopincai,代码行数:21,代码来源:ImportDmDPC.cs

示例5: C

        public static void C(string name, string type, int length, string output)
        {
            int count = (int)Math.Pow(10, length);
            List<string> list = new List<string>(10000);
            string format = "D" + length;
            for (int i = 0; i < count; i++)
            {
                var digits = i.ToString(format).ToArray();
                Permutations<char> p = new Permutations<char>(digits, length);
                List<string> pn = p.Get(",");
                if (pn.Exists(x => list.Contains(x))) continue;

                list.Add(i.Format(format, ","));
            }

            if (output.Equals("txt"))
            {
                SaveToText(name, type, list);
                return;
            }

            SaveToDB(name, type, list);
        }
开发者ID:tomdeng,项目名称:gaopincai,代码行数:23,代码来源:ImportDmDPC.cs

示例6: GetItemsFiltered

    /// <summary>
    /// Gets the items filtered.
    /// </summary>
    /// <param name="filter">
    /// The filter.
    /// </param>
    /// <param name="ni">
    /// An XPathNodeIterator for the Sitecore item
    /// </param>
    /// <returns>
    /// </returns>
    private XPathNodeIterator GetItemsFiltered(string filter, XPathNodeIterator ni)
    {
      string[] arr = filter.Split(',');
      if (filter.Length == 0)
      {
        return ni;
      }

      // lager en liste over alle items i ni
      List<Item> items = this.GetItemList(ni);

      var itemList = new List<Item>();

      foreach (Item item in items)
      {
        ItemLink[] links = item.Links.GetAllLinks();
        foreach (string id in arr)
        {
          foreach (ItemLink link in links)
          {
            if (link.TargetItemID.ToString() != id)
            {
              continue;
            }

            if (!itemList.Contains(item))
            {
              itemList.Add(item);
            }
          }
        }
      }

      return new ListNodeIterator(itemList);
    }
开发者ID:HydAu,项目名称:sitecore8ecommerce,代码行数:46,代码来源:XslExtensions.cs

示例7: Init

        public void Init()
        {
            Dungeons.Add(9036, typeof(IoDDungeon));

            #region Merge_DataCenter_And_Sniffed_Spawn

            List<int> fullIds = new List<int>();

            foreach (KeyValuePair<int, List<SpawnTemplate>> keyValuePair in Data.Data.Spawns)
            {
                for (int i = 0; i < keyValuePair.Value.Count; i++)
                {
                    if (keyValuePair.Value[i].Type == 1023)
                    {
                        keyValuePair.Value.RemoveAt(i);
                        i--;
                    }
                }

                MergedSpawn.Add(keyValuePair.Key, keyValuePair.Value);

                foreach (SpawnTemplate spawnTemplate in keyValuePair.Value)
                    if (!fullIds.Contains(spawnTemplate.FullId))
                        fullIds.Add(spawnTemplate.FullId);
            }

            foreach (KeyValuePair<int, List<SpawnTemplate>> dcSpawn in Data.Data.DcSpawns)
            {
                if (!MergedSpawn.ContainsKey(dcSpawn.Key))
                {
                    MergedSpawn.Add(dcSpawn.Key, dcSpawn.Value);
                    continue;
                }

                foreach (SpawnTemplate spawnTemplate in dcSpawn.Value)
                {
                    if (!fullIds.Contains(spawnTemplate.FullId))
                        MergedSpawn[dcSpawn.Key].Add(spawnTemplate);
                }
            }

            #endregion

            foreach (KeyValuePair<int, List<SpawnTemplate>> dcSpawn in MergedSpawn)
                if (!IsDungeon(dcSpawn.Key))
                    SpawnMap(new MapInstance { MapId = dcSpawn.Key });
        }
开发者ID:ZettaZero,项目名称:TeraEmulator,代码行数:47,代码来源:MapService.cs


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