예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Started...");
            Product prod1 = new Product(10, 1);
            Product prod2 = new Product(60, 1);
            Product prod3 = new Product(10, 2);
            Product prod4 = new Product(60, 2);
            Product prod5 = new Product
            {
                Type = 1
            };

            var checker = new PriceChecker(); // Publisher

            service1 = new Service1();
            service2 = new Service2();
            service3 = new AnnouncerService();
            checker.PriceChecking += service3.PriceChecking;

            List <Product> list = new List <Product> {
                prod1, prod2, prod3, prod4, prod5
            };

            list.ForEach(p => checker.CheckPrice(p));

            Console.WriteLine("Press Enter to exit:");
            Console.ReadLine();
        }
예제 #2
0
        private async Task SendMessageCongratulations(IDialogContext context)
        {
            announcerService = new AnnouncerService();
            var card = announcerService.SendMessageCongratulations().ToAttachment();
            var msg  = context.MakeMessage();

            msg.Attachments.Add(card);
            await context.PostAsync(msg);
        }
        private void IntroductBotForNewUsers(Activity activity)
        {
            if (activity.MembersAdded != null && activity.MembersAdded.Any())
            {
                var botId = activity.Recipient.Id;
                var test  = activity.MembersAdded.Select(m => m).Where(m => m.Id != botId).ToList();

                if (activity.MembersAdded.Any(m => m.Id != botId))
                {
                    var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                    var announcer = new AnnouncerService();
                    var reply     = activity.CreateReply();

                    reply.Attachments.Add(announcer.GenerateIntroduction().ToAttachment());
                    connector.Conversations.ReplyToActivityAsync(reply);
                }
            }
        }