Esempio n. 1
0
 //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));
         }
     }
 }
Esempio n. 2
0
        public void StartVoting(VotingPattern pattern)
        {
            //CreateFakeVoting();
            CreateVoting(pattern);
            votingScope = new VotingScope {
                voting = this.voting, Name = VotingScopeName
            };
            var strBuilder = new StringBuilder(Drawer).Append(voting.ObjectOfVoting)
                             .Append(sDrawer).Append("Варианты:").Append(sDrawer);

            for (int i = 1; i < voting.Options.Count; i++)
            {
                var opt = voting.Options.ElementAt(i);
                strBuilder.Append(i + ")").Append(opt.Value).Append(" - ").Append(opt.Key).Append(sDrawer);
            }
            bot.AddInteractiveScope(votingScope.Name, votingScope);
            bot.SendMessage(Drawer + " " + strBuilder);
        }