Click here to Skip to main content
15,884,099 members
Articles / Programming Languages / C#

Observer Design Pattern (Delegates/Events)

Rate me:
Please Sign up or sign in to vote.
4.84/5 (23 votes)
9 Aug 2009CPOL3 min read 71.1K   589   67  
This article uses Delegates/Events to implement an Observer Design Pattern.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace www.askbargains.com.ObserverDesignPartternLib
{
    public class FamilyDoctor
    {
        private Dictionary<string, Kid> _kids = new Dictionary<string, Kid>();

        public Dictionary<string, Kid> Paitients
        {
            get { return _kids; }
            set { _kids = value; }
        }


        public void ReciveNotes(string paitientName)
        {
            Console.WriteLine("Family Doctor received {0}'s new daily status. updates on: {1} . Notes:{2}", Paitients[paitientName].Name, Paitients[paitientName].DailyStatus.UpdatedOn, Paitients[paitientName].DailyStatus.Description);
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
Sr Software Architect.Microsoft Certified Solutions Developer (MCSD).

Comments and Discussions