public IRankVoteCounter2 CreateRankVoteCounter(RankVoteCounterMethod rankVoteCounterMethod)
        {
            IRankVoteCounter2 rankVoteCounter = rankVoteCounterMethod switch
            {
                RankVoteCounterMethod.RIRV => (IRankVoteCounter2) new RatedInstantRunoff(),
                RankVoteCounterMethod.Baldwin => new Baldwin(),
                RankVoteCounterMethod.Schulze => new Schulze(),
                RankVoteCounterMethod.Wilson => new Wilson(),
                RankVoteCounterMethod.Default => new RatedInstantRunoff(),
                _ => throw new ArgumentOutOfRangeException($"Unknown rank vote counter type: {rankVoteCounterMethod}", nameof(rankVoteCounterMethod))
            };

            return(rankVoteCounter);
        }
    }
示例#2
0
        public TallyOutput(
            IVoteCounter counter,
            RankVoteCounterFactory rankVoteCounterFactory,
            ForumAdapterFactory forumAdapterFactory,
            IGeneralOutputOptions options)
        {
            voteCounter   = counter;
            outputOptions = options;

            rankVoteCounter = rankVoteCounterFactory.CreateRankVoteCounter(options.RankVoteCounterMethod);

            if (voteCounter.Quest != null)
            {
                quest        = voteCounter.Quest;
                forumAdapter = forumAdapterFactory.CreateForumAdapter(quest.ForumType, quest.ThreadUri);
            }
            else
            {
                quest        = new Quest();
                forumAdapter = forumAdapterFactory.CreateForumAdapter(ForumType.Unknown, Quest.InvalidThreadUri);
            }
        }