annotate 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
rev   line source
101
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
1 using AltNetHispano.Agendas.Domain.Exceptions;
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
2
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
3 namespace AltNetHispano.Agendas.Domain
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
4 {
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
5 public class EventoNullState : EventoState
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
6 {
104
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
7 private EventoNullState()
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
8 {
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
9 }
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
10
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
11 private static readonly EventoState _instance = new EventoNullState();
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
12 public static EventoState GetInstance()
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
13 {
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
14 return _instance;
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
15 }
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
16
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
17 private const string Descripcion = "NullState";
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
18
103
23325dddddcc Persistencia del estado de los eventos
jorge.rowies
parents: 101
diff changeset
19 public override void Promover(Evento evento, Accion accion)
101
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
20 {
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
21 switch (accion)
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
22 {
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
23 case Accion.Proponer:
104
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
24 evento.SetEstado(EventoPropuestoState.GetInstance());
103
23325dddddcc Persistencia del estado de los eventos
jorge.rowies
parents: 101
diff changeset
25 evento.AddTrack(new Track(evento, Accion.Proponer));
101
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
26 break;
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
27 case Accion.Agendar:
104
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
28 evento.SetEstado(EventoAgendadoState.GetInstance());
103
23325dddddcc Persistencia del estado de los eventos
jorge.rowies
parents: 101
diff changeset
29 evento.AddTrack(new Track(evento, Accion.Agendar));
101
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
30 break;
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
31 default:
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
32 throw new AccionNoSoportadaException(this.GetType(), accion);
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
33 }
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
34 }
103
23325dddddcc Persistencia del estado de los eventos
jorge.rowies
parents: 101
diff changeset
35
23325dddddcc Persistencia del estado de los eventos
jorge.rowies
parents: 101
diff changeset
36 public override string GetDescripcion()
23325dddddcc Persistencia del estado de los eventos
jorge.rowies
parents: 101
diff changeset
37 {
104
c5034884c7d7 refactor para que los estados sean singletons
jorge.rowies
parents: 103
diff changeset
38 return Descripcion;
103
23325dddddcc Persistencia del estado de los eventos
jorge.rowies
parents: 101
diff changeset
39 }
101
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
40 }
9bfdd5bf3ad2 Manejo de estados de los Eventos mediante state pattern (primer version)
jorge.rowies
parents:
diff changeset
41 }