示例#1
0
        public void Pray(BadMan husband, RunArgs args)
        {
            //拉来的数据
            var location = husband.Location;

            Console.WriteLine("老婆为远在:{0}的老公祈祷", location);
            if (args.NewLocation == "海南")
            {
                args.Cancel = true;
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            BadMan man    = new BadMan();
            Police police = new Police();
            Wife   wife   = new Wife();

            police.GoOut += man.RunAway;


            man.Run += new RunAwaryHandler(police.CatchBadMan);
            man.Run += wife.Pray;

            man.Run += (sender, arguments) =>
            {
                Console.WriteLine("热心市民:在{0}看到一个罪犯", arguments.NewLocation);
            };

            man.RunAway("南宁");
            man.RunAway("海南");
            Console.WriteLine("现在所在位置:{0}", man.Location);

            police.Gogogo();
        }
示例#3
0
 public void CatchBadMan(BadMan target, RunArgs args)
 {
     //推来的数据
     Console.WriteLine("警察撤销:{0}的警力,重新在:{1}部属警力", args.OldLocaion, args.NewLocation);
 }