本文整理汇总了C#中Model.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# List.Contains方法的具体用法?C# List.Contains怎么用?C# List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveSelectionCommand
public RemoveSelectionCommand(List<Atom> atomsToRemove, List<Binding> bindingsToRemove, ObservableCollection<Atom> atoms, ObservableCollection<Binding> bindings)
{
this.atomsToRemove = atomsToRemove;
this.atoms = atoms;
this.bindings = bindings;
List<Binding> additionalBindingsToRemove = new List<Binding>();
foreach (Binding b in bindings)
{
if (atomsToRemove.Contains(b.BindingPoint1) || atomsToRemove.Contains(b.BindingPoint2))
{
additionalBindingsToRemove.Add(b);
}
}
foreach (Binding b in additionalBindingsToRemove)
{
if (!bindingsToRemove.Contains(b))
{
bindingsToRemove.Add(b);
}
}
this.bindingsToRemove = bindingsToRemove;
}
示例2: DelSubject
public static void DelSubject(List<Priority> SP, List<String> SubjectID)
{
List<String> SB = new List<String>();
if (SubjectID != null)
{
foreach (var r in SP)
if (!SubjectID.Contains(r.SubjectID.ToString()))
SB.Add(r.SubjectID);
}
else
{
foreach (var r in SP)
SB.Add(r.SubjectID);
}
for (int i = 0; i < SB.Count(); i++)
{
var a = SB[i];
var nhom = (from m in InputHelper.db.nhoms
where m.MaMonHoc.Equals(a)
select m.Nhom1).ToList();
foreach (var r in nhom)
{
byte aByte = Convert.ToByte(r);
InputHelper.Groups.FirstOrDefault(m => m.Value.MaMonHoc == SB[i] && m.Value.Nhom == aByte).Value.IsIgnored = false;
}
OutputHelper.SaveOBJ("Groups", InputHelper.Groups);
}
}
示例3: Sentence
/// </summary>
/// <param name="first_verse">First verse in sentence</param>
/// <param name="start_position">Position in verse of first letter of first word in sentence</param>
/// <param name="last_verse">Last verse in sentence</param>
/// <param name="end_position">Position in verse of last letter of last word in sentence</param>
/// <param name="text">Complete text of sentence within its verse or across multiple verses</param>
public Sentence(Verse first_verse, int start_position, Verse last_verse, int end_position, string text)
{
this.first_verse = first_verse;
this.start_position = start_position;
this.last_verse = last_verse;
this.end_position = end_position;
this.text = text;
this.chapter_count = last_verse.Chapter.Number - first_verse.Chapter.Number + 1;
this.verse_count = last_verse.Number - first_verse.Number + 1;
string text_mode = first_verse.Book.Title;
string simplified_text = this.text.SimplifyTo(text_mode);
this.word_count = simplified_text.Split().Length;
this.letter_count = simplified_text.Length - word_count + 1;
List<char> unique_letters = new List<char>();
foreach (char letter in simplified_text)
{
if (letter == ' ') continue;
if (!unique_letters.Contains(letter))
{
unique_letters.Add(letter);
}
}
this.unique_letter_count = unique_letters.Count;
}
示例4: SelectOnlyCoveredTests
private void SelectOnlyCoveredTests(TestsRootNode rootNode, List<MethodIdentifier> coveredTests)
{
rootNode.IsIncluded = false;
var toSelect = rootNode.Children.SelectManyRecursive(n => n.Children, leafsOnly: true)
.OfType<TestNodeMethod>()
.Where(t => coveredTests.Contains(t.Identifier));
foreach (var testNodeMethod in toSelect)
{
testNodeMethod.IsIncluded = true;
}
}
示例5: Loadpro_cookie
//Getpro cookie
public List<ESHOP_NEW> Loadpro_cookie(int type, List<string> listnews_url)
{
try
{
var list=db.ESHOP_NEWs.Where(n=>n.NEWS_TYPE == type&& listnews_url.Contains(n.NEWS_SEO_URL)).Distinct().OrderByDescending(n => n.NEWS_PUBLISHDATE).OrderByDescending(n => n.NEWS_ORDER_PERIOD).ToList();
return list;
}
catch (Exception)
{
throw;
}
}
示例6: ListaPaises
public static List<string> ListaPaises()
{
List<string> ListaCultura = new List<string>();
CultureInfo[] SelecionarCultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
foreach (CultureInfo SelecionarCultura in SelecionarCultureInfo)
{
RegionInfo SelecionarRegionInfo = new RegionInfo(SelecionarCultura.LCID);
if (!(ListaCultura.Contains(SelecionarRegionInfo.DisplayName)))
{
ListaCultura.Add(SelecionarRegionInfo.DisplayName);
}
}
ListaCultura.Sort();
return ListaCultura;
}
示例7: GetResults
protected override int GetResults(Viewport viewport)
{
switch (this.tableName)
{
case "Venue":
{
var q = from v in dc.Venues
from htmIds in dc.FHtmCoverRect(viewport.South, viewport.West, viewport.North, viewport.East)
where v.HtmId >= htmIds.HtmIDStart && v.HtmId <= htmIds.HtmIDEnd &&
v.Lat >= viewport.South && v.Lat <= viewport.North &&
v.Lon >= viewport.West && v.Lon <= viewport.East
orderby v.K
select new { v.K };
using (
new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }))
{
return q.Take(200).ToArray().Length;
}
}
case "Event":
{
List<int> allHardDanceMusicTypeKs = new List<int> { 10, 11, 12, 13, 14, 45, 59, 60 };
var q = from v in dc.Events
from htmIds in dc.FHtmCoverRect(viewport.South, viewport.West, viewport.North, viewport.East)
join m in dc.EventMusicTypes on v.K equals m.EventK
where v.HtmId >= htmIds.HtmIDStart && v.HtmId <= htmIds.HtmIDEnd &&
v.Lat >= viewport.South && v.Lat <= viewport.North &&
v.Lon >= viewport.West && v.Lon <= viewport.East
&& allHardDanceMusicTypeKs.Contains(m.MusicTypeK)
orderby v.K
select new { v.K };
using (
new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = IsolationLevel.ReadUncommitted }))
{
return q.Take(200).ToArray().Length;
}
}
default:
throw new NotImplementedException(this.tableName);
}
}
示例8: OnNavigatedTo
public override async void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var recipes = await _localDataService.Load("Data\\Recipes.txt");
var ds = new List<string>();
RecipeDataGroup group = null;
foreach (RecipeDataItem recipe in recipes)
{
if (!ds.Contains(recipe.Group.UniqueId))
{
group = recipe.Group;
group.Items = new ObservableCollection<RecipeDataItem>();
ds.Add(recipe.Group.UniqueId);
_recipeRepository.ItemGroups.Add(group);
}
_recipeRepository.AssignedUserImages(recipe);
if (group != null) group.Items.Add(recipe);
}
}
示例9: OnNavigatedTo
public override async Task OnNavigatedTo(NavigationEventArgs e)
{
var recipes = await _recipesService.Load("Data\\Recipes.json");
var ds = new List<string>();
RecipeDataGroup group = null;
Recipes = new ObservableCollection<RecipeDataItem>();
foreach (RecipeDataItem recipe in recipes)
{
Recipes.Add(recipe);
if (!ds.Contains(recipe.Group.UniqueId))
{
group = recipe.Group;
group.Items = new ObservableCollection<RecipeDataItem>();
ds.Add(recipe.Group.UniqueId);
_recipeRepository.ItemGroups.Add(group);
}
_recipeRepository.AssignedUserImages(recipe);
if (group != null) group.Items.Add(recipe);
}
}
示例10: PushVersion
/// <summary>
/// Pushes the version taken as a parameter
/// Will return any changes that conflicts
/// IMPORTANT: The version is not commited at the server before null is returned!
/// </summary>
/// <param name="path">The path to the repository to push</param>
/// <param name="number">The version number used to identify the right version</param>
/// <param name="log">The changes given by a number of text-.</param>
/// <param name="user">The user to submit changes.</param>
/// <returns>
/// Any changes that conflicts or null if version is commited
/// </returns>
/// <exception cref="System.ArgumentNullException">Log can't be null</exception>
/// <exception cref="System.ArgumentException">Log can't be empty</exception>
public string[][] PushVersion(String path, int number, string[] log, User user)
{
if (log == null) throw new ArgumentNullException("Log can't be null");
if (log.Length < 1) throw new ArgumentException("Log can't be empty");
if (user == null) throw new ArgumentNullException("User can't be null");
if (String.IsNullOrEmpty(user.Name)) throw new ArgumentException("User's name is invalid: " + user.Name);
if (String.IsNullOrEmpty(user.Password)) throw new ArgumentException("User's password is invalid");
if (user.MAC == null) throw new ArgumentNullException("User's MAC address is invalid (" + user.MAC + " and can therefore not push");
Console.WriteLine("[" + DateTime.Now + "]: " + "User is pushing to the server: " + user.MAC);
//See if the user is known - if not: Throw an exception
//Connect(user);
var returnArray = new string[0][];
// Test that the version number is correct - otherwise we'll just store things at the wrong places.
var vcs = new ServerVersionControlSystem(path, _fileSystem);
var currentVersion = vcs.GetLatestVersionNumber();
if (currentVersion != number - 1)
{
throw new ArgumentException("Can not push version " + number + " to the server version " + currentVersion);
}
// If the last user that attempted to push is the same as the current user, no conflicts will occur.
if (PushedLastVersion(user))
{
// We can assume that everything has been resolved client side and execute all the changes made
IList<AbstractChange> changeList = ChangeParser.ParseChanges(log).Where(item => item != null).ToList();
// Store the version
SaveChanges(number, user, vcs, changeList);
}
else
{
String[] simpleChanges = SearchForSimpleChanges(log);
String[,] complexChanges = SearchForComplexChanges(log);
ISet<String> conflictingPathsOnServerSet = new SortedSet<string>();
ISet<String> conflictingPathsOnClientSet = new SortedSet<string>();
//Get paths to all text files in project directory and all sub directories.
String absolutePath = vcs.GetFileSystemRoot() + path;
IList<String> projectFilesList = new List<string>(Directory.GetFileSystemEntries(absolutePath, "*", SearchOption.AllDirectories).Where(s => s.Contains(FileSystem.META_DIR) == false));
// Discover potential conflicts
for (int i = 0; i < projectFilesList.Count; i++)
{
projectFilesList[i] = projectFilesList[i].Substring(vcs.GetFileSystemRoot().Length);
}
foreach (String filePath in simpleChanges)
{
if (projectFilesList.Contains(filePath))
{
conflictingPathsOnServerSet.Add(filePath);
conflictingPathsOnClientSet.Add(filePath);
}
}
for (int i = 0; i < complexChanges.Length; i++)
{
if (projectFilesList.Contains(complexChanges[i, 0]))
{
conflictingPathsOnServerSet.Add(complexChanges[i, 0]);
conflictingPathsOnClientSet.Add(complexChanges[i, 1]);
}
}
// If no conflicts arises we can save the change to the file system
if (conflictingPathsOnServerSet.Count == 0)
{
SaveChanges(number, user, vcs, ChangeParser.ParseChanges(log));
}
else // Otherwise we find the conflicting paths and return the contents of the file on the
// server for the client to merge
{
IList<String> conflictingPathsOnServer = new List<string>(conflictingPathsOnServerSet);
IList<String> conflictingPathsOnClient = new List<string>(conflictingPathsOnClientSet);
var list = new List<string[]>();
for (int i = 0; i < conflictingPathsOnServer.Count; i++)
{
var fileList = new List<string>() { conflictingPathsOnClient[i] };
fileList.AddRange(vcs.ReadAllLines(conflictingPathsOnServer[i]));
list.Add(fileList.ToArray());
}
returnArray = list.ToArray();
}
//.........这里部分代码省略.........
示例11: GetPre_Order_Code
/// <summary> 提交时获取当前配件列表中存在的引用单号,保存到中间表中
/// 并生成执行的sql
/// </summary>
/// <returns></returns>
void GetPre_Order_Code(List<SysSQLString> listSql, string purchase_billing_id, string post_order_id, string post_order_code)
{
List<string> list = new List<string>();
SysSQLString sysStringSql = new SysSQLString();
sysStringSql.cmdType = CommandType.Text;
Dictionary<string, string> dic = new Dictionary<string, string>();
string sql1 = "delete from tr_order_relation where [email protected]_order_id;";
dic.Add("post_order_id", post_order_id);
dic.Add("post_order_code", post_order_code);
sysStringSql.sqlString = sql1;
sysStringSql.Param = dic;
listSql.Add(sysStringSql);
DataTable dt_relation_order = DBHelper.GetTable("查询采购开单配件表的引用单号", "tb_parts_purchase_billing_p", " purchase_billing_id,relation_order ", " purchase_billing_id='" + purchase_billing_id + "'", "", "");
if (dt_relation_order != null && dt_relation_order.Rows.Count > 0)
{
foreach (DataRow dr in dt_relation_order.Rows)
{
string relation_order = dr["relation_order"] == null ? "" : dr["relation_order"].ToString();
if (!string.IsNullOrEmpty(relation_order))
{
if (!list.Contains(relation_order))
{
list.Add(relation_order);
sysStringSql = new SysSQLString();
sysStringSql.cmdType = CommandType.Text;
dic = new Dictionary<string, string>();
dic.Add("order_relation_id", Guid.NewGuid().ToString());
dic.Add("pre_order_id", string.Empty);
dic.Add("pre_order_code", relation_order);
dic.Add("post_order_id", post_order_id);
dic.Add("post_order_code", post_order_code);
string sql2 = string.Format(@"Insert Into tr_order_relation(order_relation_id,pre_order_id,pre_order_code,
post_order_id,post_order_code) values(@order_relation_id,@pre_order_id,
@pre_order_code,@post_order_id,@post_order_code);");
sysStringSql.sqlString = sql2;
sysStringSql.Param = dic;
listSql.Add(sysStringSql);
}
}
}
}
}
示例12: VerifyExtensionConfigDiag
private bool VerifyExtensionConfigDiag(ExtensionConfigurationInput resultConfig, string storage, List<string> roles, XmlDocument wadconfig = null, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null)
{
try
{
string resultStorageAccount = GetInnerText(resultConfig.PublicConfiguration, "Name");
string resultWadCfg = Utilities.GetInnerXml(resultConfig.PublicConfiguration, "WadCfg");
if (string.IsNullOrWhiteSpace(resultWadCfg))
{
resultWadCfg = null;
}
string resultStorageKey = GetInnerText(resultConfig.PrivateConfiguration, "StorageKey");
Console.WriteLine("Type: {0}, StorageAccountName:{1}, StorageKey: {2}, WadCfg: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}",
resultConfig.Type, resultStorageAccount, resultStorageKey, resultWadCfg, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate);
Assert.AreEqual(resultConfig.Type, "Diagnostics", "Type is not equal!");
Assert.AreEqual(resultStorageAccount, storage);
Assert.IsTrue(Utilities.CompareWadCfg(resultWadCfg, wadconfig));
if (string.IsNullOrWhiteSpace(thumbprint))
{
Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint));
}
else
{
Assert.AreEqual(resultConfig.CertificateThumbprint, thumbprint, "Certificate thumbprint is not equal!");
}
if (string.IsNullOrWhiteSpace(algorithm))
{
Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm));
}
else
{
Assert.AreEqual(resultConfig.ThumbprintAlgorithm, algorithm, "Thumbprint algorithm is not equal!");
}
Assert.AreEqual(resultConfig.X509Certificate, cert, "X509Certificate is not equal!");
if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName))
{
Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString()));
}
else
{
foreach (ExtensionRole role in resultConfig.Roles)
{
Assert.IsTrue(roles.Contains(role.RoleName));
}
}
return true;
}
catch
{
return false;
}
}
示例13: VerifyExtensionConfigRDP
private bool VerifyExtensionConfigRDP(ExtensionConfigurationInput resultConfig, string user, string pass, List<string> roles, DateTime exp, string thumbprint = null, string algorithm = null, X509Certificate2 cert = null)
{
try
{
string resultUserName = GetInnerText(resultConfig.PublicConfiguration, "UserName");
string resultPassword = GetInnerText(resultConfig.PrivateConfiguration, "Password");
string resultExpDate = GetInnerText(resultConfig.PublicConfiguration, "Expiration");
Console.WriteLine("Type: {0}, UserName:{1}, Password: {2}, ExpirationDate: {3}, CertificateThumbprint: {4}, ThumbprintAlgorithm: {5}, X509Certificate: {6}",
resultConfig.Type, resultUserName, resultPassword, resultExpDate, resultConfig.CertificateThumbprint, resultConfig.ThumbprintAlgorithm, resultConfig.X509Certificate);
Assert.AreEqual(resultConfig.Type, "RDP", "Type is not equal!");
Assert.AreEqual(resultUserName, user);
Assert.AreEqual(resultPassword, pass);
Assert.IsTrue(Utilities.CompareDateTime(exp, resultExpDate));
if (string.IsNullOrWhiteSpace(thumbprint))
{
Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.CertificateThumbprint));
}
else
{
Assert.AreEqual(resultConfig.CertificateThumbprint, thumbprint, "Certificate thumbprint is not equal!");
}
if (string.IsNullOrWhiteSpace(algorithm))
{
Assert.IsTrue(string.IsNullOrWhiteSpace(resultConfig.ThumbprintAlgorithm));
}
else
{
Assert.AreEqual(resultConfig.ThumbprintAlgorithm, algorithm, "Thumbprint algorithm is not equal!");
}
Assert.AreEqual(resultConfig.X509Certificate, cert, "X509Certificate is not equal!");
if (resultConfig.Roles.Count == 1 && string.IsNullOrEmpty(resultConfig.Roles[0].RoleName))
{
Assert.IsTrue(roles.Contains(resultConfig.Roles[0].RoleType.ToString()));
}
else
{
foreach (ExtensionRole role in resultConfig.Roles)
{
Assert.IsTrue(roles.Contains(role.RoleName));
}
}
return true;
}
catch
{
return false;
}
}
示例14: GetRelatedWords
// get related words and verses
public List<Word> GetRelatedWords(Word word, bool with_diacritics)
{
List<Word> result = new List<Word>();
if (word != null)
{
Dictionary<string, List<Word>> root_words_dictionary = this.RootWords;
if (root_words_dictionary != null)
{
// try all roots in case word_text is a root
if (root_words_dictionary.ContainsKey(word.Text))
{
List<Word> root_words = root_words_dictionary[word.Text];
foreach (Word root_word in root_words)
{
Verse verse = this.Verses[root_word.Verse.Number - 1];
Word verse_word = verse.Words[root_word.NumberInVerse - 1];
if (!result.Contains(verse_word))
{
result.Add(verse_word);
}
}
}
else // if no such root, search for the matching root_word by its verse position and get its root and then get all root_words
{
string root = GetBestRoot(word.Text, with_diacritics);
if (!String.IsNullOrEmpty(root))
{
List<Word> root_words = root_words_dictionary[root];
foreach (Word root_word in root_words)
{
Verse verse = this.Verses[root_word.Verse.Number - 1];
Word verse_word = verse.Words[root_word.NumberInVerse - 1];
if (!result.Contains(verse_word))
{
result.Add(verse_word);
}
}
}
}
}
}
return result;
}
示例15: GetAlertMaintenance
public DataSet GetAlertMaintenance(int organID)
{
List<string> list = new List<string>();
string sql1 = "select FrameNO,max(Kilometre) as Count,min(MaintenanceDate) as MT from Maintenance where organID = @OrganID group by FrameNO";
string sql2 = "select FrameNO,max(KM_Count) as Count from Kilometre where organID = @OrganID group by FrameNO";
SqlParameter[] parameters = {
new SqlParameter("@OrganID",organID)
};
DataTable re1 = DbHelperSQL.Query(sql1, parameters).Tables[0];
DataTable re2 = DbHelperSQL.Query(sql2, parameters).Tables[0];
DataColumn[] keys = new DataColumn[1];
keys[0] = re2.Columns["FrameNO"];
re2.PrimaryKey = keys;
if (re1 != null || re1.Rows.Count > 0)
{
foreach (DataRow dr in re1.Rows)
{
DataRow r = re2.Rows.Find(dr["FrameNO"].ToString());
if (r != null)
{
int x = int.Parse(r["Count"].ToString()) - int.Parse(dr["Count"].ToString());
if (x >= 7000)
{
list.Add(dr["FrameNO"].ToString());
}
}
DateTime mt = DateTime.Parse(dr["MT"].ToString());
if (mt.AddMonths(5) < DateTime.Now && !list.Contains(dr["FrameNO"].ToString()))
{
list.Add(dr["FrameNO"].ToString());
}
}
}
if (list.Count > 0)
{
string fs = "";
foreach (string s in list)
{
fs += "'" + s + "',";
}
fs = fs.TrimEnd(',');
string where = " FrameNO in (" + fs + ")";
return new VehicleDAL().GetList(where);
}
else
{
return null;
}
}