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


C# System.Collections.Generic.List.Find方法代码示例

本文整理汇总了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);
            }
    }
开发者ID:jaytem,项目名称:minGit,代码行数:37,代码来源:TagDefaults.ascx.cs

示例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)
//.........这里部分代码省略.........
开发者ID:npenin,项目名称:uss,代码行数:101,代码来源:Synchronizer.cs


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