Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Domain/EventoAgendadoState.cs @ 104:c5034884c7d7
refactor para que los estados sean singletons
author | jorge.rowies |
---|---|
date | Sun, 05 Jun 2011 13:22:36 -0300 |
parents | 23325dddddcc |
children | 53bcd338542b |
comparison
equal
deleted
inserted
replaced
103:23325dddddcc | 104:c5034884c7d7 |
---|---|
2 | 2 |
3 namespace AltNetHispano.Agendas.Domain | 3 namespace AltNetHispano.Agendas.Domain |
4 { | 4 { |
5 public class EventoAgendadoState : EventoState | 5 public class EventoAgendadoState : EventoState |
6 { | 6 { |
7 public const string Descripcion = "Agendado"; | 7 private EventoAgendadoState() |
8 { | |
9 } | |
10 | |
11 private static readonly EventoState _instance = new EventoAgendadoState(); | |
12 public static EventoState GetInstance() | |
13 { | |
14 return _instance; | |
15 } | |
16 | |
17 private const string Descripcion = "Agendado"; | |
8 | 18 |
9 public override void Promover(Evento evento, Accion accion) | 19 public override void Promover(Evento evento, Accion accion) |
10 { | 20 { |
11 switch (accion) | 21 switch (accion) |
12 { | 22 { |
13 case Accion.Confirmar: | 23 case Accion.Confirmar: |
14 evento.SetEstado(new EventoConfirmadoState()); | 24 evento.SetEstado(EventoConfirmadoState.GetInstance()); |
15 evento.AddTrack(new Track(evento, Accion.Confirmar)); | 25 evento.AddTrack(new Track(evento, Accion.Confirmar)); |
16 break; | 26 break; |
17 default: | 27 default: |
18 throw new AccionNoSoportadaException(this.GetType(), accion); | 28 throw new AccionNoSoportadaException(this.GetType(), accion); |
19 } | 29 } |