Ejemplo n.º 1
0
        private void Work()
        {
            var mediaInventory = new MediaInventory();
            var recordPlayer   = new RecordPlayer();
            var cassettePlayer = new CassettePlayer();

            MediaInventory.TestMedia testRecordDelegate   = new MediaInventory.TestMedia(recordPlayer.PlayRecord);
            MediaInventory.TestMedia testCassetteDelegate = new MediaInventory.TestMedia(cassettePlayer.TestCassette);

            mediaInventory.TestResult(testCassetteDelegate);
            mediaInventory.TestResult(testRecordDelegate);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            MediaInventory mediaInv = new MediaInventory();

            mediaInv.TestResult((new RecordPlayer()).PlayRecord);
            mediaInv.TestResult((new CassettePlayer()).PlayCassette);

            // or the long form
            Console.WriteLine("\n----");
            MediaInventory.TestMedia testRecordDelegate =
                new MediaInventory.TestMedia((new RecordPlayer()).PlayRecord);
            mediaInv.TestResult(testRecordDelegate);

            MediaInventory.TestMedia testCassDelegate =
                new MediaInventory.TestMedia((new CassettePlayer()).PlayCassette);
            mediaInv.TestResult(testCassDelegate);
        }