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


C# List.Distinct方法代码示例

本文整理汇总了C#中Data.List.Distinct方法的典型用法代码示例。如果您正苦于以下问题:C# List.Distinct方法的具体用法?C# List.Distinct怎么用?C# List.Distinct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Data.List的用法示例。


在下文中一共展示了List.Distinct方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SearchForIssues

        public string SearchForIssues(string[] tags)
        {
            if (tags.Length <= 0)
            {
                return Constants.NoTagsProvidedMsg;
            }

            var issues = new List<Issue>();
            foreach (var t in tags)
            {
                issues.AddRange(this.Data.IssuesByTag[t]);
            }

            if (!issues.Any())
            {
                return Constants.NoIssuesMatchingTheTagProvidedMsg;
            }

            var uniqueIssues = issues.Distinct();
            if (!uniqueIssues.Any())
            {
                return Constants.NoIssuesMsg;
            }

            return string.Join(Environment.NewLine, uniqueIssues.OrderByDescending(x => x.Priority).ThenBy(x => x.Title));
        }
开发者ID:AngataHristov,项目名称:High-Quality-Code,代码行数:26,代码来源:IssueTracker.cs

示例2: GetUserRoles

        public List<Role> GetUserRoles(string username)
        {
            var aUser = userRepository.GetSingleUserByName(username);

            if(aUser == null)
                throw new ApplicationException("User does not exist");

            List<Role> aLIst = new List<Role>();

            foreach (UserRole usrRole in aUser.UserRole)
            {
                aLIst.Add(usrRole.Role);
            }
            return aLIst.Distinct().ToList();
        }
开发者ID:hidden666,项目名称:Shop-engine,代码行数:15,代码来源:MembershipService.cs

示例3: SearchForIssues

        public string SearchForIssues(string[] tags)
        {
            // If there are no tags provided, the action returns There are no tags provided
            if (tags.Length < 0)
            {
                return "There are no tags provided";
            }

            var issues = new List<Issue>();
            foreach (var tag in tags)
            {
                issues.AddRange(this.Data.Tag_Issues[tag]);
            }

            // If there are no matching issues, the action returns There are no issues matching the tags provided
            if (!issues.Any())
            {
                return "There are no issues matching the tags provided";
            }

            // If an issue matches several tags, it is included only once in the search results. 
            var uniqueIssues = issues.Distinct();

            // In case of success, the action returns the issues sorted by priority (in descending order) first, and by title (in alphabetical order) next. 
            return string.Join(
                Environment.NewLine,
                uniqueIssues.OrderByDescending(x => x.Priority).ThenBy(x => x.Title));
        }
开发者ID:EBojilova,项目名称:CSharpHQC,代码行数:28,代码来源:IssueTracker.cs

示例4: SearchForIssues

        public string SearchForIssues(string[] tags) {
            if (tags.Length <= 0)
            {
                return "There are no tags provided";
            }

            var issues = new List<Issue>();
            foreach (var tag in tags)
            {
                issues.AddRange(this.Data.IssuesByTag[tag]);
            }
            if (!issues.Any())
            {
                return "There are no issues matching the tags provided";
            }

            var distinctIssues = issues.Distinct();
            if (!distinctIssues.Any())
            {
                return "No issues";
            }

            var orderedDistinctIssues =
                distinctIssues
                .OrderByDescending(i => i.Priority)
                .ThenBy(i => i.Title)
                .Select(i => i.ToString());
            return string.Join(Environment.NewLine, orderedDistinctIssues);
        }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:29,代码来源:BuhtigIssueTracker.cs

示例5: MainWindow_OnActivated

        private void MainWindow_OnActivated(object sender, EventArgs e)
        {
            if (FirstTimeActivated)
            {
                FirstTimeActivated = false;

                //Try to login with the saved credentials.
                if (!Auth.Login(Config.Instance.Username, Config.Instance.Password).Item1)
                {
                    ShowLoginDialog();
                }
                else
                {
                    OnLogin(Config.Instance.Username);
                }

                var allAssemblies = new List<LeagueSharpAssembly>();
                foreach (var profile in Config.Instance.Profiles)
                {
                    allAssemblies.AddRange(profile.InstalledAssemblies);
                }

                allAssemblies = allAssemblies.Distinct().ToList();

                GitUpdater.ClearUnusedRepos(allAssemblies);
                PrepareAssemblies(allAssemblies, Config.Instance.FirstRun || Config.Instance.UpdateOnLoad, true, true);
                Remoting.Init();
            }

            var text = Clipboard.GetText();
            if (text.StartsWith(LSUriScheme.FullName))
            {
                Clipboard.SetText("");
                LSUriScheme.HandleUrl(text, this);
            }
        }
开发者ID:eddy5641,项目名称:LeagueSharp.Loader,代码行数:36,代码来源:MainWindow.xaml.cs

示例6: SearchForIssues

        public string SearchForIssues(string[] strings) {
            if (strings.Length < 0)
                return "There are no tags provided";

            var i = new List<Problem>();
            foreach (var t in strings)
                i.AddRange(Data.issues4[t]);
            if (!i.Any())
                return "There are no issues matching the tags provided";
            var newi = i.Distinct();
            if (!newi.Any())
            {
                return "No issues";
            }
            return string.Join(Environment.NewLine, newi.OrderByDescending(x => x.Priority).ThenBy(x => x.Title).Select(x => string.Empty));
        }
开发者ID:exploitx3,项目名称:HighQualityCode,代码行数:16,代码来源:moreStuff.cs


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