Exemple #1
0
        static void Main(string[] args)
        {
            var a  = new Subject1();
            var b1 = new Obserber1(a);
            var b2 = new Obserber1(a);
            var b3 = new Obserber1(a);
            var b4 = new Obserber1(a);
            var b5 = new Obserber1(a);

            b3.Flag = false;

            b1.Tag = "x";
            b2.Tag = "xx";
            b3.Tag = "xxx";
            b4.Tag = "xxxx";
            b5.Tag = "xxxxx";


            b1.register();
            b2.register();
            b5.register();
            b3.register();
            b4.register();
            //按注册顺序增加 并遍历发送

            a.setParameter1(1, 2);
        }
Exemple #2
0
        public void remove(Obserber1 obserber1)
        {
            var index = OberserList.IndexOf(obserber1);

            if (index > 0)
            {
                OberserList.Remove(obserber1);
            }
        }
Exemple #3
0
 public void register(Obserber1 obserber1)
 {
     OberserList.Add(obserber1);
 }