[smuxi] Frontend: avoid logic in State ctors



commit 5bd7b2ecb8b12ac30525cb8d4a9ac3350e996bf1
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Tue Jul 22 16:53:41 2014 +0200

    Frontend: avoid logic in State ctors

 src/Frontend/ChatViewSyncManager.cs |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/Frontend/ChatViewSyncManager.cs b/src/Frontend/ChatViewSyncManager.cs
index 7700fcd..aea6530 100644
--- a/src/Frontend/ChatViewSyncManager.cs
+++ b/src/Frontend/ChatViewSyncManager.cs
@@ -68,6 +68,10 @@ namespace Smuxi.Frontend
                 Chat = chat;
             }
 
+            public virtual void Init()
+            {
+            }
+
             public virtual void ExecuteAdd()
             {
                 throw new InvalidStateException("could not add in " + this.GetType().Name);
@@ -113,6 +117,10 @@ namespace Smuxi.Frontend
             public AddedState(SyncInfo chat)
                 :base(chat)
             {
+            }
+
+            public override void Init()
+            {
 #if LOG4NET
                 DateTime start = DateTime.UtcNow;
 #endif
@@ -199,6 +207,10 @@ namespace Smuxi.Frontend
             public SyncingState(SyncInfo chat)
                 :base(chat)
             {
+            }
+
+            public override void Init()
+            {
 #if LOG4NET
                 DateTime start = DateTime.UtcNow;
 #endif
@@ -245,6 +257,10 @@ namespace Smuxi.Frontend
             public RemovingState(SyncInfo chat)
                 :base(chat)
             {
+            }
+
+            public override void Init()
+            {
                 Chat.Manager.OnChatRemoved(Chat.ChatView);
             }
 
@@ -280,6 +296,7 @@ namespace Smuxi.Frontend
             public void SetState<T>() where T : State
             {
                 State = (T)Activator.CreateInstance(typeof(T), this);
+                State.Init();
             }
 
             public void ExecuteAdd()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]