diff 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
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Domain/EventoNullState.cs	Sun Jun 05 13:06:23 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Domain/EventoNullState.cs	Sun Jun 05 13:22:36 2011 -0300
@@ -4,16 +4,28 @@
 {
   public class EventoNullState : EventoState
   {
+    private EventoNullState()
+    {
+    }
+
+    private static readonly EventoState _instance = new EventoNullState();
+    public static EventoState GetInstance()
+    {
+      return _instance;
+    }
+
+    private const string Descripcion = "NullState";
+
     public override void Promover(Evento evento, Accion accion)
     {
       switch (accion)
       {
         case Accion.Proponer:
-          evento.SetEstado(new EventoPropuestoState());
+          evento.SetEstado(EventoPropuestoState.GetInstance());
           evento.AddTrack(new Track(evento, Accion.Proponer));
           break;
         case Accion.Agendar:
-          evento.SetEstado(new EventoAgendadoState());
+          evento.SetEstado(EventoAgendadoState.GetInstance());
           evento.AddTrack(new Track(evento, Accion.Agendar));
           break;
         default:
@@ -23,7 +35,7 @@
 
     public override string GetDescripcion()
     {
-      return "NullState";
+      return Descripcion;
     }
   }
 }
\ No newline at end of file