本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.List.Find方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.List.Find方法的具体用法?C# System.Collections.Generic.List.Find怎么用?C# System.Collections.Generic.List.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.List
的用法示例。
在下文中一共展示了System.Collections.Generic.List.Find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveDefaults
private void SaveDefaults()
{
string newTags = "";
if (! (Request.Form["newTags"] == null))
{
newTags = Request.Form["newTags"].Trim();
}
string[] newTagsArray = newTags.Split(";".ToCharArray());
System.Collections.Generic.List<string> newTagsList = new System.Collections.Generic.List<string>(newTagsArray);
Hashtable originalTagHT = new Hashtable();
string orginalTagList;
orginalTagList = Request.Form["originalTags"].Trim();
//loop through existing default tags and make sure they havent been removed - if so delete them
//also - build up a hashtable of original default tags so we can reference them later
//both tag lists are stored in following format: <TagText>~<LanguageID>;<TagText>~<LanguageID>;
string[] origTagsArray = orginalTagList.Split(";".ToCharArray());
foreach (string tag in origTagsArray)
{
chkTag = tag;
originalTagHT.Add(tag, "");
string tagMatch = (string) (newTagsList.Find(FindTagByName));
if (string.IsNullOrEmpty(tagMatch))
{
m_tagApi.RemoveTagAsDefault(tag, m_containerPage.ContentLanguage, defaultTagObjectType);
}
}
// loop throug tagdata stored in newtags field
foreach (string tag in newTagsList)
{
m_tagApi.SaveTagAsDefault(tag, m_containerPage.ContentLanguage, defaultTagObjectType);
}
}
示例2: OptimizeCommands
/// <summary>
/// Creates Compound commands if necessary
/// </summary>
/// <param name="commands"></param>
private Command[] OptimizeCommands(SyncEngine engine, IList<Entity> commands)
{
if (commands == null)
throw new ArgumentNullException("commands");
if (commands.Count == 0)
return new Command[0];
HashedList<Command> optimizedCommands = new HashedList<Command>();
System.Collections.Generic.List<CompoundCreateCommand> createdCommands = new System.Collections.Generic.List<CompoundCreateCommand>();
int j;
for (int i = 0; i < commands.Count; i++)
{
Entity e = commands[i];
string currentId = e.GetString(SyncUtils.PARENTID);
int transaction = e.GetInt32(SyncUtils.TRANSACTION);
switch (e.Type)
{
case SyncUtils.CREATE_ENTITY:
string createType = e.GetString(SyncUtils.TYPE);
j = i + 1;
CompoundCreateCommand ccc = new CompoundCreateCommand(currentId, createType, new List<AttributeCommand>());
CompoundCreateCommand actual = createdCommands.Find(delegate(CompoundCreateCommand toFind)
{
return toFind.ClientId == ccc.ClientId &&
toFind.ParentId == ccc.ParentId &&
toFind.Type == ccc.Type;
});
if (actual == null)
{
createdCommands.Add(ccc);
optimizedCommands.Add(ccc);
while (j < commands.Count)
{
string subType = commands[j].GetString(SyncUtils.PARENTTYPE);
string subId = commands[j].GetString(SyncUtils.PARENTID);
int subTransaction = commands[j].GetInt32(SyncUtils.TRANSACTION);
string subCommand = commands[j].Type;
if (commands[j].Type == SyncUtils.CREATE_ATTRIBUTE && subId == currentId && subType == createType)
{
if (subTransaction != transaction)
break;
ccc.InnerCommands.Add((AttributeCommand)engine.CreateCommand(commands[j]));
commands.RemoveAt(j);
}
else
{
j++;
}
}
}
else
{
optimizedCommands.Remove(actual);
optimizedCommands.Add(ccc);
createdCommands.Remove(actual);
createdCommands.Add(ccc);
}
break;
case SyncUtils.UPDATE_ATTRIBUTE:
string updateType = e.GetString(SyncUtils.PARENTTYPE);
j = i + 1;
CompoundUpdateCommand cuc = new CompoundUpdateCommand(currentId, updateType, new List<AttributeCommand>());
cuc.InnerCommands.Add((AttributeCommand)engine.CreateCommand(commands[i]));
optimizedCommands.Add(cuc);
while (j < commands.Count)
{
string subType = commands[j].GetString(SyncUtils.PARENTTYPE);
string subId = commands[j].GetString(SyncUtils.PARENTID);
int subTransaction = commands[j].GetInt32(SyncUtils.TRANSACTION);
string subCommand = commands[j].Type;
if (commands[j].Type == SyncUtils.UPDATE_ATTRIBUTE && subId == currentId && subType == updateType)
{
if (subTransaction != transaction)
//.........这里部分代码省略.........