public IActionResult Index()
        {
            AdminObserver    observer1 = new AdminObserver();
            ActivityObserver observer2 = new ActivityObserver();
            ForumNotifier    notifier  = new ForumNotifier();

            notifier.Subscribe(observer1);
            notifier.Subscribe(observer2);

            //cache.Set("notifier", notifier);

            return(View());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ModeratorObserver obs1     = new ModeratorObserver();
            ActivityObserver  obs2     = new ActivityObserver();
            BlogNotifier      notifier = new BlogNotifier();

            notifier.Subscribe(obs1);
            notifier.Subscribe(obs2);

            BlogPost post = new BlogPost();

            post.Id       = 1;
            post.UserName = "******";
            post.Title    = "Hellow World!";
            Console.WriteLine("Please enter blog post body:");
            post.Body     = Console.ReadLine();
            post.PostDate = DateTime.Now;

            // logic to save the post

            notifier.Notify(post);
        }