예제 #1
0
        /// <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();
        }
예제 #2
0
        void Caller()
        {
            BaseDocument doc   = new DocumentA();
            BaseDocument decor = new DocumentDecoratorForLogging()
            {
                doc = doc
            };

            decor.Create();
        }
예제 #3
0
        /// <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();
        }
예제 #4
0
        void Caller()
        {
            Employee emp1 = new Bookkeeper();
            Employee emp2 = new Manager();

            emp1.Successor = emp2;


            BaseDocument doc = new DocumentA();

            emp1.ProcessDocument(doc);
        }
예제 #5
0
        /// <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();
        }
예제 #6
0
        void Caller()
        {
            IDocument doc = null;

            doc = new DocumentA();
            doc.Create();


            doc = new DocumentB();
            doc.Create();


            BaseDocument document = new DocumentB();

            document.Save();
        }
예제 #7
0
        /// <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);
        }
예제 #8
0
        void Caller()
        {
            BaseDocument doc = null;

            doc = new DocumentA()
            {
                RenderingStrategy = new RenderingStrategyTabbed()
            };
            doc.Render();


            doc = new DocumentB()
            {
                RenderingStrategy = new RenderingStrategySinglePage()
            };
            doc.Render();
        }