Fixes recursion bug in disambiguate_in().
[ohcount] / test / expected_dir / cs1.cs
1 csharp  comment // The Delegate declaration which defines the signature of methods which can be invoked
2 csharp  code    public delegate void ScoreChangeEventHandler (int newScore, ref bool cancel);
3 csharp  blank   
4 csharp  comment // Class which makes the event
5 csharp  code    public class Game {
6 csharp  comment     // Note the use of the event keyword
7 csharp  code        public event ScoreChangeEventHandler ScoreChange;
8 csharp  blank   
9 csharp  code        int score;
10 csharp  blank   
11 csharp  comment         // Score Property
12 csharp  code        public int Score {
13 csharp  code            get {
14 csharp  code                return score;
15 csharp  code                }
16 csharp  code            set {
17 csharp  code                if (score != value) {
18 csharp  code                    bool cancel = false;
19 csharp  code                    ScoreChange (value, ref cancel);
20 csharp  code                    if (! cancel)
21 csharp  code                        score = value;
22 csharp  code                }
23 csharp  code            }
24 csharp  code        }
25 csharp  code    }
26 csharp  blank   
27 csharp  comment // Class which handles the event
28 csharp  code    public class Referee
29 csharp  code    {
30 csharp  code        public Referee (Game game) {
31 csharp  comment         // Monitor when a score changes in the game
32 csharp  code            game.ScoreChange += new ScoreChangeEventHandler (game_ScoreChange);
33 csharp  code        }
34 csharp  blank   
35 csharp  comment     // Notice how this method signature matches the ScoreChangeEventHandler's signature
36 csharp  code        private void game_ScoreChange (int newScore, ref bool cancel) {
37 csharp  code            if (newScore < 100)
38 csharp  code                System.Console.WriteLine ("Good Score");
39 csharp  code            else {
40 csharp  code                cancel = true;
41 csharp  code                System.Console.WriteLine ("No Score can be that high!");
42 csharp  code            }
43 csharp  code        }
44 csharp  code    }
45 csharp  blank   
46 csharp  comment // Class to test it all
47 csharp  code    public class GameTest
48 csharp  code    {
49 csharp  code        public static void Main () {
50 csharp  code            Game game = new Game ();
51 csharp  code            Referee referee = new Referee (game);
52 csharp  code            game.Score = 70;
53 csharp  code            game.Score = 110;
54 csharp  code        }
55 csharp  code    }