comparison Agendas/trunk/src/Agendas.Domain/EventoNullState.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 EventoNullState : EventoState 5 public class EventoNullState : EventoState
6 { 6 {
7 private EventoNullState()
8 {
9 }
10
11 private static readonly EventoState _instance = new EventoNullState();
12 public static EventoState GetInstance()
13 {
14 return _instance;
15 }
16
17 private const string Descripcion = "NullState";
18
7 public override void Promover(Evento evento, Accion accion) 19 public override void Promover(Evento evento, Accion accion)
8 { 20 {
9 switch (accion) 21 switch (accion)
10 { 22 {
11 case Accion.Proponer: 23 case Accion.Proponer:
12 evento.SetEstado(new EventoPropuestoState()); 24 evento.SetEstado(EventoPropuestoState.GetInstance());
13 evento.AddTrack(new Track(evento, Accion.Proponer)); 25 evento.AddTrack(new Track(evento, Accion.Proponer));
14 break; 26 break;
15 case Accion.Agendar: 27 case Accion.Agendar:
16 evento.SetEstado(new EventoAgendadoState()); 28 evento.SetEstado(EventoAgendadoState.GetInstance());
17 evento.AddTrack(new Track(evento, Accion.Agendar)); 29 evento.AddTrack(new Track(evento, Accion.Agendar));
18 break; 30 break;
19 default: 31 default:
20 throw new AccionNoSoportadaException(this.GetType(), accion); 32 throw new AccionNoSoportadaException(this.GetType(), accion);
21 } 33 }
22 } 34 }
23 35
24 public override string GetDescripcion() 36 public override string GetDescripcion()
25 { 37 {
26 return "NullState"; 38 return Descripcion;
27 } 39 }
28 } 40 }
29 } 41 }