コード例 #1
0
ファイル: TallyOutput.cs プロジェクト: FairFolk/NetTally
        /// <summary>
        /// Generate output for any ranked votes that were tallied.
        /// </summary>
        private void ConstructRankedOutput(CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            if (VoteCounter.Instance.HasRankedVotes)
            {
                IRankVoteCounter  counter = VoteCounterLocator.GetRankVoteCounter(AdvancedOptions.Instance.RankVoteCounterMethod);
                RankResultsByTask results = counter.CountVotes(VoteCounter.Instance.GetVotesCollection(VoteType.Rank));

                //var orderedRes = results.OrderBy(a => a.Key);
                var orderedRes = results;

                // Output the ranking results for each task
                foreach (var task in orderedRes)
                {
                    token.ThrowIfCancellationRequested();

                    AddRankTask(task);
                    sb.AppendLine("");
                }

                // Output the total number of voters
                AddTotalVoterCount(VoteInfo.RankedVoterCount);
                sb.AppendLine("");
            }
        }
コード例 #2
0
        /// <summary>
        /// Generate output for any ranked votes that were tallied.
        /// </summary>
        private void ConstructRankedOutput(CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            if (VoteCounter.HasRankedVotes)
            {
                IRankVoteCounter  counter = VoteCounterLocator.GetRankVoteCounter(AdvancedOptions.Instance.RankVoteCounterMethod);
                RankResultsByTask results = counter.CountVotes(VoteCounter.GetVotesCollection(VoteType.Rank));

                IOrderedEnumerable <KeyValuePair <string, RankResults> > orderedRes;

                if (ViewModelService.MainViewModel.VoteCounter.OrderedTaskList != null)
                {
                    orderedRes = results.OrderBy(v => ViewModelService.MainViewModel.VoteCounter.OrderedTaskList.IndexOf(v.Key));
                }
                else
                {
                    orderedRes = results.OrderBy(a => a.Key);
                }

                // Output the ranking results for each task
                foreach (var task in orderedRes)
                {
                    token.ThrowIfCancellationRequested();

                    AddRankTask(task);
                    sb.AppendLine("");
                }

                // Output the total number of voters
                AddTotalVoterCount(VoteInfo.RankedVoterCount);
                sb.AppendLine("");
            }
        }