本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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 });
}