本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.Contains方法的具体用法?C# System.Collections.Generic.List.Contains怎么用?C# System.Collections.Generic.List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetReworkedMatches
public List<int> GetReworkedMatches()
{
List<int> answer = new List<int>();
var currCopy = CurrentPositions.GetRange(0, CurrentPositions.Count);
var startMatchesCopy = new System.Collections.Generic.List<int>();
foreach (var item in StartMatches)
{
startMatchesCopy.Add(item);
};
foreach (var item in currCopy)
{
if (!startMatchesCopy.Contains(item))
answer.Add(item);
}
return answer;
}
示例2: Import
/// <summary>
/// Imports (create) a document from a xmlrepresentation of a document, used by the packager
/// </summary>
/// <param name="ParentId">The id to import to</param>
/// <param name="Creator">Creator of the new document</param>
/// <param name="Source">Xmlsource</param>
public static int Import(int ParentId, User Creator, XmlElement Source)
{
// check what schema is used for the xml
bool sourceIsLegacySchema = Source.Name.ToLower() == "node" ? true : false;
// check whether or not to create a new document
int id = int.Parse(Source.GetAttribute("id"));
Document d = null;
if (Document.IsDocument(id))
{
try
{
// if the parent is the same, we'll update the existing document. Else we'll create a new document below
d = new Document(id);
if (d.ParentId != ParentId)
d = null;
}
catch { }
}
// document either didn't exist or had another parent so we'll create a new one
if (d == null)
{
string nodeTypeAlias = sourceIsLegacySchema ? Source.GetAttribute("nodeTypeAlias") : Source.Name;
d = MakeNew(
Source.GetAttribute("nodeName"),
DocumentType.GetByAlias(nodeTypeAlias),
Creator,
ParentId);
}
else
{
// update name of the document
d.Text = Source.GetAttribute("nodeName");
}
d.CreateDateTime = DateTime.Parse(Source.GetAttribute("createDate"));
// Properties
string propertyXPath = sourceIsLegacySchema ? "data" : "* [not(@isDoc)]";
foreach (XmlElement n in Source.SelectNodes(propertyXPath))
{
string propertyAlias = sourceIsLegacySchema ? n.GetAttribute("alias") : n.Name;
Property prop = d.getProperty(propertyAlias);
string propValue = xmlHelper.GetNodeValue(n);
if (prop != null)
{
// only update real values
if (!String.IsNullOrEmpty(propValue))
{
//test if the property has prevalues, of so, try to convert the imported values so they match the new ones
SortedList prevals = cms.businesslogic.datatype.PreValues.GetPreValues(prop.PropertyType.DataTypeDefinition.Id);
//Okey we found some prevalue, let's replace the vals with some ids
if (prevals.Count > 0)
{
System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>(propValue.Split(','));
foreach (DictionaryEntry item in prevals)
{
string pval = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Value;
string pid = ((umbraco.cms.businesslogic.datatype.PreValue)item.Value).Id.ToString();
if (list.Contains(pval))
list[list.IndexOf(pval)] = pid;
}
//join the list of new values and return it as the new property value
System.Text.StringBuilder builder = new System.Text.StringBuilder();
bool isFirst = true;
foreach (string str in list)
{
if (!isFirst)
builder.Append(",");
builder.Append(str);
isFirst = false;
}
prop.Value = builder.ToString();
}
else
prop.Value = propValue;
}
}
else
{
LogHelper.Warn<Document>(String.Format("Couldn't import property '{0}' as the property type doesn't exist on this document type", propertyAlias));
}
}
//.........这里部分代码省略.........
示例3: PrepareForSerialization
/// <summary>
/// Property helper for Files & WordFiles, ensures the data retrieved
/// from those two properties is 'in sync'
/// </summary>
private void PrepareForSerialization()
{
if (_SerializePreparationDone) return;
_FileList = new List<File>();
_WordfileArray = new CatalogWordFile[_Index.Count];
Word[] wordArray = new Word[_Index.Count];
_Index.Values.CopyTo(wordArray, 0);
// go through all the words
for (int i = 0; i < wordArray.Length; i++)
{
// first, add all files to the 'flist' collection
foreach (File f in wordArray[i].Files)
{
if (!_FileList.Contains(f))
{
_FileList.Add(f);
}
}
// now go through again and use the indexes
CatalogWordFile wf = new CatalogWordFile();
wf.Text = wordArray[i].Text;
foreach (File f in wordArray[i].Files)
{
wf.FileIds.Add(_FileList.IndexOf(f));
}
_WordfileArray[i] = wf;
}
_SerializePreparationDone = true;
}
示例4: ShowSelectedOrganization
public void ShowSelectedOrganization(string childrenYK, ObjectList<Organization> orgs, Organization m_provider)
{
this.provider = m_provider;
System.Collections.Generic.List<Organization> list = new System.Collections.Generic.List<Organization>();
foreach (Organization organization in orgs)
{
if ((organization.ToString() == childrenYK) && !list.Contains(organization))
{
list.Add(organization);
break;
}
}
foreach (Organization organization2 in list)
{
base.Nodes.Add(new OrganizationNode(organization2, m_provider));
}
}
示例5: Test_AddDirectoryByName_Nested
public void Test_AddDirectoryByName_Nested()
{
Directory.SetCurrentDirectory(TopLevelDir);
var dirsAdded = new System.Collections.Generic.List<String>();
string zipFileToCreate = Path.Combine(TopLevelDir, "Test_AddDirectoryByName_Nested.zip");
using (ZipFile zip1 = new ZipFile())
{
for (int n = 1; n <= 14; n++)
{
string DirName = n.ToString();
for (int i = 0; i < n; i++)
{
// create an arbitrary directory name, add it to the zip archive
DirName = Path.Combine(DirName, TestUtilities.GenerateRandomAsciiString(11));
}
zip1.AddDirectoryByName(DirName);
dirsAdded.Add(DirName.Replace("\\", "/") + "/");
}
zip1.Save(zipFileToCreate);
}
int dirCount = 0;
using (ZipFile zip2 = FileSystemZip.Read(zipFileToCreate))
{
foreach (var e in zip2)
{
TestContext.WriteLine("dir: {0}", e.FileName);
Assert.IsTrue(dirsAdded.Contains(e.FileName), "Cannot find the expected directory.");
Assert.IsTrue(e.IsDirectory);
dirCount++;
}
}
Assert.AreEqual<int>(dirsAdded.Count, dirCount);
}
示例6: GenerateMovementTree
// CALL THIS EVERY TIME A UNIT GETS A NEW TURN
public static void GenerateMovementTree(UnitActions mover)
{
System.Collections.Generic.List<Tile> all = new System.Collections.Generic.List<Tile>();
//optimization
int mx = (int)mover.gridPosition.x;
int my = (int)mover.gridPosition.y;
int mxmin = mx - mover.MovementTiles;
int mxmax = mx + mover.MovementTiles;
int mymin = my - mover.MovementTiles;
int mymax = my + mover.MovementTiles;
if (mxmin < 0)
mxmin = 0;
if (mxmax >= GameManager.MapWidth)
mxmax = GameManager.MapWidth - 1;
if (mymin < 0)
mymin = 0;
if (mymax >= GameManager.MapHeight)
mymax = GameManager.MapHeight - 1;
Tile temp = GetTileFromPlayer(mover);
for (int i = mxmin; i <= mxmax; ++i)
{
for (int j = mymin; j <= mymax; ++j)
{
if (GetDistance(temp, GameManager.map[i][j]) < mover.MovementTiles + 1)
if (true) //TODO replace this with a check to see if the mover can walk on map[i][j]
all.Add(GameManager.map[i][j]);
}
}
//TODO This will need to be tweaked if we allow movement through allied units
//if allied movement is desired, this foreach can be removed to allow it, but you'll need to manually remove player location tiles
// from the output of getmovement or they'll be able to walk into each other
//uncomment this to make it so that allied units block player movement
/*foreach (Player p in GameManager.currentTeam.myRoster)
{
temp = GetTileFromPlayer(p);
if (all.Contains(temp))
all.Remove(temp);
}*/
foreach (UnitActions p in GameManager.enemyTeam.myRoster)
{
temp = GetTileFromPlayer(p);
if (all.Contains(temp))
all.Remove(temp);
}
//Dijkstra's Algorithm
Dictionary<Tile, int> weights = new Dictionary<Tile, int>();
List<Tile> unvisited = new List<Tile>();
Dictionary<Tile, Tile> nextParent = new Dictionary<Tile, Tile>();
foreach (Tile t in all)
{
weights.Add(t, Infinity);
unvisited.Add(t);
}
temp = GetTileFromPlayer(mover);
weights[temp] = 0;
unvisited.Remove(temp);
CurrentMovementTree.Clear();
CurrentMovementTree.Value = temp;
while (unvisited.Count > 0)
{
List<Tile> uvn = GetUnvisitedNeighbors(unvisited, temp);
int dist;
foreach (Tile t in uvn)
{
float jdist = t.elevation - temp.elevation;
if (jdist < 0)
jdist *= -1;
if (t.isAccessible && jdist <= mover.MovementJump)
dist = t.MoveCost + weights[temp];
else
dist = Infinity;
if (dist < weights[t])
{
weights[t] = dist;
if (nextParent.ContainsKey(t))
nextParent[t] = temp;
else
nextParent.Add(t, temp);
}
}
if (unvisited.Count > 0)
{
temp = unvisited[0];
foreach (Tile t in weights.Keys)
{
if (unvisited.Contains(t) && weights[t] < weights[temp])
temp = t;
}
}
unvisited.Remove(temp);
}
Queue<Tile> distancecheck = new Queue<Tile>();
foreach (Tile t in nextParent.Keys)
{
distancecheck.Enqueue(t);
}
Queue<Tile> Remove = new Queue<Tile>();
while (distancecheck.Count > 0)
//.........这里部分代码省略.........
示例7: FillTreeViewColoringShowStatusTypeCombobox
private void FillTreeViewColoringShowStatusTypeCombobox()
{
//System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>();
// Shows
foreach (string status in Enum.GetNames(typeof(ShowItem.ShowAirStatus)))
{
ShowStatusColoringType t = new ShowStatusColoringType(true, true, status);
//System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>("Show Seasons Status: " + status, new ShowStatusColoringType(true, true, status));
this.cboShowStatus.Items.Add(t);
//this.cboShowStatus.Items.Add("Show Seasons Status: " + status);
}
System.Collections.Generic.List<string> showStatusList = new System.Collections.Generic.List<string>();
List<ShowItem> shows = this.mDoc.GetShowItems(false);
foreach (var show in shows)
{
if(!showStatusList.Contains(show.ShowStatus))
showStatusList.Add(show.ShowStatus);
}
foreach (string status in showStatusList)
{
ShowStatusColoringType t = new ShowStatusColoringType(false, true, status);
//System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>("Show Status: " + status, new ShowStatusColoringType(false, true, status));
this.cboShowStatus.Items.Add(t);
}
//this.cboShowStatus.Items.Add(new System.Collections.Generic.KeyValuePair<string, object>("Show Seasons Status: Custom", null));
// Seasons
foreach (string status in Enum.GetNames(typeof(Season.SeasonStatus)))
{
ShowStatusColoringType t = new ShowStatusColoringType(true, false, status);
//System.Collections.Generic.KeyValuePair<string, object> item = new System.Collections.Generic.KeyValuePair<string, object>("Seasons Status: " + status, new ShowStatusColoringType(true, false, status));
this.cboShowStatus.Items.Add(t);
//this.cboShowStatus.Items.Add("Seasons Status: " + status);
}
this.cboShowStatus.DisplayMember = "Text";
//this.cboShowStatus.ValueMember = ";
}
示例8: getNearestNode
private int getNearestNode( Vector3 pos, params int[] excludeNodes )
{
var excludeNodesList = new System.Collections.Generic.List<int>( excludeNodes );
var bestDistance = float.MaxValue;
var index = -1;
var distance = float.MaxValue;
for( var i = _target.nodes.Count - 1; i >= 0; i-- )
{
if( excludeNodesList.Contains( i ) )
continue;
distance = Vector3.Distance( pos, _target.nodes[i] );
if( distance < bestDistance )
{
bestDistance = distance;
index = i;
}
}
return index;
}
示例9: RefreshTreeviewNodeFormatting
private void RefreshTreeviewNodeFormatting(TreeNode treeNode)
{
Cursor origCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
//if (isFolder(treeNode))
if (treeNode.Nodes.Count > 0)
{
// First rename (title) the node items...
//value = "{get_accession.accession_number_part1} + \" \" + {get_accession.accession_number_part2} + \" \" + {get_accession.accession_number_part3}; ";
System.Collections.Generic.Dictionary<string, string> idTypeFormattingFormula = new System.Collections.Generic.Dictionary<string, string>();
System.Collections.Generic.List<string> idTypes = new System.Collections.Generic.List<string>();
System.Collections.Generic.Dictionary<string, string> idNumbers = new System.Collections.Generic.Dictionary<string, string>();
DataSet ds = new DataSet();
// First find all of the distinct ID_TYPES,
// their corresponding formatting formulas,
// and gather all of the ID_NUMBERS for each ID_TYPE in the userItemList collection...
foreach (TreeNode tn in treeNode.Nodes)
{
if (!isFolder(tn))
{
//string pKey = tn.Tag.ToString().Split(';')[1].Trim();
//string nodePKeyType = pKey.Split('=')[0].Replace(":", "").Trim().ToUpper();
//string nodePKeyValue = pKey.Split('=')[1].Trim().ToUpper();
string[] pKey = tn.Name.Split('=');
string nodePKeyType = pKey[0];
string nodePKeyValue = pKey[1];
// Get the ID_TYPE...
if (!idTypes.Contains(nodePKeyType)) idTypes.Add(nodePKeyType);
// Now get the formatting formula for each ID_TYPE in the collection...
if (!idTypeFormattingFormula.ContainsKey(nodePKeyType))
{
//string formula = GetTreeviewNodeProperty(nodePKeyType + "_NAME_FORMULA", tn);
string formula = GetTreeviewNodeProperty(tn.Tag.ToString().Split(';')[0].Trim().ToUpper() + "_NAME_FORMULA", tn, true, "");
if (string.IsNullOrEmpty(formula))
{
// Could not find a formula for this type of treenode object type...
}
idTypeFormattingFormula.Add(nodePKeyType, formula);
}
// Next collect all of the ID_NUMBERS for each of the ID_TYPES for the userItemList collection...
if (!idNumbers.ContainsKey(nodePKeyType))
{
idNumbers.Add(nodePKeyType, nodePKeyValue + ",");
}
else
{
idNumbers[nodePKeyType] = idNumbers[nodePKeyType] + nodePKeyValue + ",";
}
}
else
{
if (ux_checkboxIncludeSubFolders.Checked)
{
RefreshTreeviewNodeFormatting(tn);
}
}
}
Dictionary<string, Dictionary<int, string>> friendlyNames = new Dictionary<string,Dictionary<int,string>>();
// Make all the trips to the server now to get all data needed for new userItemList titles...
foreach (string idType in idTypes)
{
// Create the new dictionary LU for the friendly name and add it to the collection...
friendlyNames.Add(idType, new Dictionary<int, string>());
// Break down the name formula into tokens and process the tokens one by one...
string[] formatTokens = idTypeFormattingFormula[idType].Split(new string[] { " + " }, StringSplitOptions.RemoveEmptyEntries);
string staticTextSeparator = "";
foreach (string formatToken in formatTokens)
{
if (formatToken.Contains("{") &&
formatToken.Contains("}"))
{
// This is a DB field used in the title - so if we don't already have it go get it now...
string[] dataviewAndField = formatToken.Trim().Replace("{", "").Replace("}", "").Trim().Split(new char[] { '.' });
if (!ds.Tables.Contains(dataviewAndField[0]))
{
DataSet newDS = _sharedUtils.GetWebServiceData(dataviewAndField[0], idType.Trim().ToLower() + "=" + idNumbers[idType].Trim().TrimEnd(','), 0, 0);
if (newDS != null &&
newDS.Tables.Contains(dataviewAndField[0]))
{
ds.Tables.Add(newDS.Tables[dataviewAndField[0]].Copy());
}
else if (newDS.Tables.Contains("ExceptionTable") &&
newDS.Tables["ExceptionTable"].Rows.Count > 0)
{
GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data from {0} to use in building a node friendly name.\n\nFull error message:\n{1}", "Get Name Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
ggMessageBox.Name = "RefreshTreeviewNodeFormatting1";
_sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
//if (ggMessageBox.MessageText.Contains("{0}") &&
// ggMessageBox.MessageText.Contains("{1}"))
//{
// ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0], newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
//}
//else if (ggMessageBox.MessageText.Contains("{0}"))
//{
// ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0]);
//.........这里部分代码省略.........
示例10: Unicode_AddDirectoryByName_wi8984
public void Unicode_AddDirectoryByName_wi8984()
{
string format = "弹出应用程序{0:D3}.dir"; // Chinese characters
System.Text.Encoding UTF8 = System.Text.Encoding.GetEncoding("UTF-8");
TestContext.WriteLine("== WorkItem 8984");
// three trials: one for old-style
// ProvisionalAlternateEncoding, one for "AsNecessary"
// and one for "Always"
for (int j=0; j < 3; j++)
{
TestContext.WriteLine("Trial {0}", j);
for (int n = 1; n <= 10; n++)
{
TestContext.WriteLine("nEntries {0}", n);
var dirsAdded = new System.Collections.Generic.List<String>();
var zipFileToCreate = String.Format("wi8984-{0}-{1:N2}.zip", j, n);
using (ZipFile zip1 = new ZipFile(zipFileToCreate))
{
switch (j)
{
case 0:
#pragma warning disable 618
zip1.UseUnicodeAsNecessary = true;
#pragma warning restore 618
break;
case 1:
zip1.AlternateEncoding = UTF8;
zip1.AlternateEncodingUsage = ZipOption.AsNecessary;
break;
case 2:
zip1.AlternateEncoding = UTF8;
zip1.AlternateEncodingUsage = ZipOption.Always;
break;
}
for (int i = 0; i < n; i++)
{
// create an arbitrary directory name, add it to the zip archive
string dirName = String.Format(format, i);
zip1.AddDirectoryByName(dirName);
dirsAdded.Add(dirName + "/");
}
zip1.Save();
}
string extractDir = String.Format("extract-{0}-{1:D3}", j, n);
int dirCount = 0;
using (ZipFile zip2 = ZipFile.Read(zipFileToCreate))
{
foreach (var e in zip2)
{
TestContext.WriteLine("dir: {0}", e.FileName);
Assert.IsTrue(dirsAdded.Contains(e.FileName), "Cannot find the expected entry ({0})", e.FileName);
Assert.IsTrue(e.IsDirectory);
e.Extract(extractDir);
dirCount++;
}
}
Assert.AreEqual<int>(n, dirCount);
TestContext.WriteLine("");
}
TestContext.WriteLine("");
}
}
示例11: CreatePropertyAccessorsForShapeInternal
private void CreatePropertyAccessorsForShapeInternal(PresentationElementClass domainElement, bool hasBaseClass)
{
#line default
#line hidden
#line 318 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("#region Shape Properties\r\n");
#line default
#line hidden
#line 320 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
AttributedDomainElement temp = domainElement;
System.Collections.Generic.List<string> handledProperty = new System.Collections.Generic.List<string>();
while(temp != null )
{
foreach(DomainProperty property in temp.Properties)
{
if( handledProperty.Contains(property.Name) )
continue;
handledProperty.Add(property.Name);
AccessModifier setterAccessModifier = property.SetterAccessModifier;
AccessModifier getterAccessModifier = property.GetterAccessModifier;
AccessModifier overallAccessModifier;
if(setterAccessModifier==AccessModifier.Public || getterAccessModifier==AccessModifier.Public)
{
overallAccessModifier = AccessModifier.Public;
}
else if(setterAccessModifier==AccessModifier.FamilyOrAssembly || getterAccessModifier==AccessModifier.FamilyOrAssembly)
{
overallAccessModifier = AccessModifier.FamilyOrAssembly;
}
else if(setterAccessModifier==AccessModifier.Family || getterAccessModifier==AccessModifier.Family)
{
overallAccessModifier = AccessModifier.Family;
}
else if(setterAccessModifier==AccessModifier.Assembly || getterAccessModifier==AccessModifier.Assembly)
{
overallAccessModifier = AccessModifier.Assembly;
}
else
{
overallAccessModifier = AccessModifier.Private;
}
string modifier = "";
//if( hasBaseClass )
// modifier = " new";
//if( p.IsElementName )
#line default
#line hidden
#line 362 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write("/// <summary>\r\n/// Gets or sets the value of ");
#line default
#line hidden
#line 364 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(property.Name));
#line default
#line hidden
#line 364 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" domain property.\r\n/// </summary>\r\n");
#line default
#line hidden
#line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetAccessModifier(overallAccessModifier)));
#line default
#line hidden
#line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(modifier));
#line default
#line hidden
#line 366 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\ViewModel\DiagramGeneratorHelper.tt"
this.Write(" ");
//.........这里部分代码省略.........
示例12: LoadServiceTypeGroupByGroupTypeId
private void LoadServiceTypeGroupByGroupTypeId(int groupTypeId)
{
this.combGroupName.Items.Clear();
ObjectList<ServiceTypeGroupPermit> list = ServiceTypeGroupPermit.FindByGroupTypeId(groupTypeId);
if ((list == null) || (list.get_Count() == 0))
{
System.Collections.Generic.List<int> list2 = new System.Collections.Generic.List<int>();
foreach (ServiceTypeGroup group in ObjectWithId.FindAll<ServiceTypeGroup>())
{
if (((group.GroupTypeId == this.m_GroupTypeId) && !group.GroupName.Equals("")) && !list2.Contains(group.Code))
{
this.combGroupName.Items.Add(((int) group.Code) + "." + group.GroupName);
list2.Add(group.Code);
}
}
this.radioNewGroup.set_Enabled(true);
this.btnChangeNameGroup.set_Enabled(true);
}
else
{
foreach (ServiceTypeGroupPermit permit in list.ApplySort("Name"))
{
this.combGroupName.Items.Add(((int) permit.Code) + "." + permit.Name);
}
this.radioNewGroup.set_Enabled(false);
this.btnChangeNameGroup.set_Enabled(false);
}
if (this.combGroupName.Items.get_Count() > 0)
{
this.combGroupName.set_SelectedIndex(0);
this.btnChangeNameGroup.set_Enabled(true);
}
else
{
this.btnChangeNameGroup.set_Enabled(false);
}
}
示例13: BindTags
private void BindTags()
{
System.Collections.Generic.List<string> col = new System.Collections.Generic.List<string>();
foreach (Training cls in Training.Trainings)
{
foreach (string tag in cls.Tags)
{
if (!col.Contains(tag))
col.Add(tag);
}
}
foreach (Curricula cls in Curricula.Curriculas)
{
foreach (string tag in cls.Tags)
{
if (!col.Contains(tag))
col.Add(tag);
}
}
col.Sort(delegate(string s1, string s2) { return String.Compare(s1, s2); });
foreach (string tag in col)
{
HtmlAnchor a = new HtmlAnchor();
a.HRef = "javascript:void(0)";
a.Attributes.Add("onclick", "AddTag(this)");
a.InnerText = tag;
phTags.Controls.Add(a);
}
}
示例14: buttonExchNoCountries_Click
private void buttonExchNoCountries_Click(object sender, EventArgs e)
{
string[] split = textBoxNoCountries.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
List<string> dictionary = new System.Collections.Generic.List<string>();
foreach (string s in split)
{
string ext = s.Substring(s.IndexOf(":") + 1);
if (!dictionary.Contains(ext))
{
dictionary.Add(ext);
Console.WriteLine(ext);
}
}
}
示例15: buttonExchange_Click
private void buttonExchange_Click(object sender, EventArgs e)
{
//string test = "ABC:PNK";
//string ext = test.Substring(test.IndexOf(":") + 1);
string sourceDirectory = @"ScreenerUSOnly";
//Dictionary<string, string> dictionary = new System.Collections.Generic.Dictionary<string,string>;
List<string> dictionary = new System.Collections.Generic.List<string>();
try
{
var txtFiles = Directory.EnumerateFiles(sourceDirectory);
foreach (string currentFile in txtFiles)
{
//string fileName = currentFile.Substring(sourceDirectory.Length + 1);
string content = System.IO.File.ReadAllText(currentFile);
//Match m = Regex.Match(content, @"value=""(.+?)""", RegexOptions.IgnoreCase | RegexOptions.Singleline);
MatchCollection mm = Regex.Matches(content, @"value=""(.+?)""", RegexOptions.IgnoreCase | RegexOptions.Singleline);
//if (mm.Count == 0)
// continue;
foreach (Match match in mm) {
string ext = match.Groups[1].Value;
string exchange = ext.Substring(ext.IndexOf(":") + 1);
if (!dictionary.Contains(exchange))
dictionary.Add(exchange);
}
}
}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}
foreach (string item in dictionary)
{
Console.WriteLine(item);
}
}