/// <summary> /// Define an object that encapsula teshow a set o f objects interac t.Mediat or promotes ///loose coupling by keeping objects from referring to each other explicitly, and it ///lets you vary their interaction independently. /// </summary> void Caller() { DocumentsCoordinator mediator = new DocumentsCoordinator(new HashSet <BaseDocument>() { new DocumentA(), new DocumentB() }); BaseDocument doc = new DocumentA(); doc.SendCoordinationAction(); }
void Caller() { BaseDocument doc = new DocumentA(); BaseDocument decor = new DocumentDecoratorForLogging() { doc = doc }; decor.Create(); }
/// <summary> /// Allow an object to alter its behavior when its internal state changes. The object ///will appear to change its class. /// </summary> void Caller() { BaseDocument doc = null; doc = new DocumentA(); doc.State = new DocumentEditableState() { Document = doc }; doc.Confirm(); }
void Caller() { Employee emp1 = new Bookkeeper(); Employee emp2 = new Manager(); emp1.Successor = emp2; BaseDocument doc = new DocumentA(); emp1.ProcessDocument(doc); }
/// <summary> /// Define a one-to-many dependency between objects so that when one object ///changes state, all its dependents are notified and updated automatically. /// </summary> void Caller() { BaseDocument doc = null; doc = new DocumentA() { Owners = new List <Employee>() { new Manager(), new Bookkeeper() } }; doc.Create(); }
void Caller() { IDocument doc = null; doc = new DocumentA(); doc.Create(); doc = new DocumentB(); doc.Create(); BaseDocument document = new DocumentB(); document.Save(); }
/// <summary> /// Without violating encapsulation, capture and externalize an object's internal state ///so that the object can be restored to this state later. /// </summary> void Caller() { BaseDocument doc = null; doc = new DocumentA() { Name = "my Name" }; MementoMamanger manager = new MementoMamanger() { Memento = doc.CreateMemento() }; doc.StoreFromMemento(manager.Memento); }
void Caller() { BaseDocument doc = null; doc = new DocumentA() { RenderingStrategy = new RenderingStrategyTabbed() }; doc.Render(); doc = new DocumentB() { RenderingStrategy = new RenderingStrategySinglePage() }; doc.Render(); }