//public void PrintVotingResults() //{ // var sBuilder = new StringBuilder(Drawer).Append(" "); // sBuilder.Append(voting.ObjectOfVoting).Append(" Результаты голосования: ").Append(Drawer); // foreach(var opt in voting.Options) // { // sBuilder.Append(opt.Value) // .Append(" - ") // .Append(voting.Votes.Where(x => x.Value == opt.Key).Count().ToString()) // .Append(" голосов ") // .Append(Drawer); // } // bot.SendMessage(sBuilder.ToString()); //} private void CreateVoting(VotingPattern pattern) { voting = pattern.Voting; foreach (var typeName in pattern.ResultEventsNames) { Type t = Type.GetType(typeName); if (t != null) { voting.ResultEvents.Add((IVotingResultEvent)Activator.CreateInstance(t)); } } }
public void CancelVoting() { if (votingScope != null) { bot.RemoveInteractiveScope(votingScope.Name); } foreach (var resultEvent in voting.ResultEvents) { resultEvent.InvokeEvent(bot, voting); } votingScope = null; voting = null; }
private void CreateFakeVoting() { var options = new Dictionary <string, string> { ["opt1"] = "options1 value", ["opt2"] = "options2 value" }; voting = new Voting { Options = options, ObjectOfVoting = "тестовое голосование", ResultEvents = new List <IVotingResultEvent> { new BaseResultEvent() }, Votes = new Dictionary <string, string>() }; }