public bool handle(Message message) { //TThrow if can't handle, basically to discourage sending messages indiscriminantly if (!can_handle(message)) { throw new ArgumentException("Check can_handle first!"); } ObjectCreationMessage creationMessage = message as ObjectCreationMessage; return(_repo.add_item(creationMessage.pos, creationMessage.value, false)); }
static void Main(string[] args) { Repository repo = new Repository(10); repo.add_item(1, 9, false); IProjection valueProjection = new Projections.AllUnitProjection(repo); IProjection occupiedProjection = new Projections.SpaceOccupiedProjection(repo); IProjection threatenedProjection = new Projections.ThreatenedProjection(repo); Console.WriteLine("Values"); valueProjection.present(); Console.WriteLine(""); Console.WriteLine("Occupation"); occupiedProjection.present(); Console.WriteLine(""); Console.WriteLine("Threatened"); threatenedProjection.present(); Console.WriteLine(""); Console.Read(); }