This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Bus : IBus | |
| { | |
| // this is our dependency that will publish the message to a queue (or somewhere else) | |
| private IMessageDispatcher messageDispatcher; | |
| public void Publish<T>(Action<T> action) where T : IMessage | |
| { | |
| var newInstance = CreateInstance<T>(); | |
| // pass the new instance to the action (by reference) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| public class Program | |
| { | |
| public static void Main() | |
| { | |
| Brush brush = new Brush(); | |
| brush.ChooseColor(c => c); | |
| Console.WriteLine("Choose Default: {0}", brush.Color); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Order | |
| { | |
| private Customer customer; | |
| public Order(Customer customer) | |
| { | |
| this.customer = customer; | |
| } | |
| // snip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Order | |
| { | |
| private Customer customer; | |
| private ISendEmail sendEmail; | |
| public Order(Customer customer, ISendEmail sendEmal) | |
| { | |
| this.customer = customer; | |
| this.sendEmail = sendEmail; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Order | |
| { | |
| private Customer customer; | |
| public Order(Customer customer) | |
| { | |
| this.customer = customer; | |
| } | |
| // snip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Order | |
| { | |
| private Customer customer; | |
| public Order(Customer customer) | |
| { | |
| this.customer = customer; | |
| } | |
| // snip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OrderingService | |
| { | |
| private ISendEmail sendEmail; | |
| public OrderingService(ISendEmail sendEmail) | |
| { | |
| this.sendEmail = sendEmail; | |
| } | |
| // snip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| describe('Game of Life', function () { | |
| var game; | |
| beforeEach(function () { | |
| game = Game(30); | |
| }); | |
| it('should create a new 30 x 30 grid', function () { | |
| expect(game.grid().length).toBe(30); | |
| expect(game.grid()[0].length).toBe(30); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Game = (function () { | |
| return function() { | |
| return {}; | |
| }; | |
| })(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Game = (function () { | |
| var _grid; | |
| var init = function (size) { | |
| _grid = []; | |
| for (var x = size - 1; x >= 0; x--) { | |
| var row = []; | |
| for (var y = size - 1; y >= 0; y--) { | |
| row.push(0); |