protected void DoCompleted(ILQHsmMemento memento) { HsmMementoCompleted handler = Completed; if (null != handler) { handler(this, memento); } }
private void cmd_SaveCompleted(IQSimpleCommand command, ILQHsmMemento memento) { SaveCmd cmd = (SaveCmd)command; using (StreamWriter sw = new StreamWriter(cmd.FileName)) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(sw.BaseStream, memento); } }
public static void FillMementoWithStateName(ILQHsmMemento memento, Type hsmType, string currentStateName, object arg) { System.Reflection.MethodInfo methodInfo = hsmType.GetMethod ("S_" + currentStateName); if (methodInfo == null) { string msg = string.Format ("State name [{0}] not found in Hsm {1}/{2}", currentStateName, hsmType, arg); throw new InvalidOperationException (msg); } memento.CurrentStateMethod = methodInfo; }
public void SpecialCase_RestoreHistoryStatesRelatedToCurrentState(ILQHsmMemento memento) { if (s_TimeKeeping_Date.Method == this.CurrentStateMethod) { _TimeKeeping_DeepHistory = s_TimeKeeping_Date; } else if (s_TimeKeeping_Time.Method == this.CurrentStateMethod) { _TimeKeeping_DeepHistory = s_TimeKeeping_Time; } }
private void RestoreHsmFromFile() { using (StreamReader sr = new StreamReader(_StorageFileName)) { BinaryFormatter bf = new BinaryFormatter(); object obj = bf.Deserialize(sr.BaseStream); ILQHsmMemento memento = (ILQHsmMemento)obj; RestoreCmd cmd = new RestoreCmd(_Book, memento); cmd.Completed += new HsmMementoCompleted(cmd_RestoreCompleted); _Book.EventManager.AsyncDispatch(cmd); } }
protected override void SaveHistoryStates(ILQHsmMemento memento) { base.SaveHistoryStates(memento); if (null == _TimeKeeping_DeepHistory) { memento.AddHistoryState("TimeKeeping", null); } else { memento.AddHistoryState("TimeKeeping", _TimeKeeping_DeepHistory.Method); } }
protected override void RestoreHistoryStates(ILQHsmMemento memento) { base.RestoreHistoryStates(memento); IStateMethodInfo stateInfo_TimeKeeping = memento.GetHistoryStateFor("TimeKeeping"); if (null == stateInfo_TimeKeeping) { _TimeKeeping_DeepHistory = null; } else { _TimeKeeping_DeepHistory = (QState)Delegate.CreateDelegate(typeof(QState), this, stateInfo_TimeKeeping.Method.Name); } }
public void SaveToMemento(ILQHsmMemento memento) { ModelInformation modelInformation = this.ModelInformation; memento.ModelVersion = modelInformation.ModelVersion; memento.ModelGuid = modelInformation.Guid; memento.Id = this.Id; memento.GroupId = this.GroupId; memento.CurrentState = this.CurrentState; SaveHistoryStates(memento); SaveFields(memento); }
public void RestoreFromMemento(ILQHsmMemento memento) { ModelInformation modelInformation = this.ModelInformation; if (modelInformation.Guid != memento.ModelGuid) { string msg = string.Format("Hsm Guid [{0}] is not the same as contained by the Memento [{1}]", modelInformation.Guid, memento.ModelGuid); throw new InvalidOperationException(msg); } _UniqueName = memento.Id; _GroupId = memento.GroupId; this.CurrentState = memento.CurrentState; RestoreHistoryStates(memento); RestoreFields(memento); LogRestored(); }
protected virtual void SaveFields(ILQHsmMemento memento) { }
public static void FillMementoWithStateName(ILQHsmMemento memento, ILQHsm hsm, string currentStateName) { FillMementoWithStateName (memento, hsm.GetType (), currentStateName, hsm); }
public static void FillMementoWithStateName(ILQHsmMemento memento, ILQHsm hsm, string currentStateName) { memento.CurrentState.Name = currentStateName; }
public RestoreCmd(ILQHsm hsm, ILQHsmMemento memento) : base(hsm) { _Memento = memento; }
protected virtual void RestoreFields(ILQHsmMemento memento) { }
protected virtual void RestoreHistoryStates(ILQHsmMemento memento) { }
protected virtual void SaveFields(ILQHsmMemento memento) { }
protected override void RestoreFields(ILQHsmMemento memento) { _DueDate = (DateTime)memento.GetFieldFor("DueDate").Value; }
protected virtual void RestoreFields(ILQHsmMemento memento) { }
public void SaveToMemento(ILQHsmMemento memento) { ModelInformation modelInformation = this.ModelInformation; memento.ModelVersion = modelInformation.ModelVersion; memento.ModelGuid = modelInformation.Guid; memento.Id = this.Id; memento.GroupId = this.GroupId; memento.CurrentStateMethod = this.CurrentStateMethod; SaveHistoryStates (memento); SaveFields (memento); }
public void RestoreFromMemento(ILQHsmMemento memento) { ModelInformation modelInformation = this.ModelInformation; if (modelInformation.Guid != memento.ModelGuid) { string msg = string.Format ("Hsm Guid [{0}] is not the same as contained by the Memento [{1}]", modelInformation.Guid, memento.ModelGuid); throw new InvalidOperationException (msg); } _UniqueName = memento.Id; _GroupId = memento.GroupId; this.CurrentStateMethod = memento.CurrentStateMethod; RestoreHistoryStates (memento); RestoreFields (memento); LogRestored (); }
private void cmd_RestoreCompleted(IQSimpleCommand command, ILQHsmMemento memento) { DoStateChange(_Book); }
protected virtual void SaveHistoryStates(ILQHsmMemento memento) { }
protected override void SaveFields(ILQHsmMemento memento) { memento.AddField("DueDate", _DueDate, typeof(DateTime)); }