/// <summary> /// Publish news as the Twitter app /// </summary> public static void PublishNews() { // Publisher GlobantNews globantNews = new GlobantNews(); // Suscribers Tweeter1 tweeter1 = new Tweeter1(globantNews); Tweeter2 tweeter2 = new Tweeter2(globantNews); // PublishNews globantNews.PublishNews("News about Observer pattern"); // Remove the first one globantNews.RemoveObserver(tweeter1); // Publish another news globantNews.PublishNews("News #2"); Console.ReadLine(); }
/// <summary> /// Initializes a new instance of the <see cref="Tweeter1"/> class /// <paramref name="globantNews"/>GlobantNews instance /// </summary> public Tweeter1(GlobantNews globantNews) { _globantNews = globantNews; _globantNews.AddObserver(this); }