Add observer pattern

Update memento pattern examples class to have run as static method
Update behavioral patterns program.cs to maintain the order
This commit is contained in:
Petrutiu Mihai
2016-06-23 21:39:13 +03:00
parent 2894347140
commit c66816b938
11 changed files with 224 additions and 19 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace ObserverPattern.Twits
{
/// <summary>
/// Concrete observer
/// </summary>
public class TwitUser : IObserver<string>
{
string name;
public TwitUser(string name)
{
this.name = name;
}
public void OnCompleted()
{
Console.WriteLine("{0} finished watching twitter", name);
}
public void OnError(Exception error)
{
Console.WriteLine("Error while watching twitter: {0}", error);
}
public void OnNext(string value)
{
Console.WriteLine("{0} just observed that something {1} was tweeted", name, value);
}
}
}