public void Rollback(RollbackInfo rollbackInfo) { foreach (var tag in rollbackInfo.Tags) { this[tag.Key] = tag.Value; } ChangeFileName(rollbackInfo.OldFileName); }
public void Dispose() { if (!_fileChanged) { return; } var data = new RollbackInfo(GetId3Data().ToList(), FilePath, _oldFilePath); new RollbackManager(_saver).AddAction(data).Dispose(); }
private void SaveRollBackInfo(int exIndex, int patIndex) { RollbackInfo info = new RollbackInfo(); info.exIndex = exIndex; info.patIndex = patIndex; if (rollBackStack == null) { rollBackStack = new Stack <RollbackInfo>(); } rollBackStack.Push(info); }
//--------------------------------------------------------------------- private void RequestPopRollback(UIWindow currentWin) { if (m_InRequestRollback || m_RollbackStack.Count == 0) { return; } m_InRequestRollback = true; RollbackInfo info = m_RollbackStack.Peek(); if (!CanRollback(currentWin) || info.source != currentWin) { m_InRequestRollback = false; return; } int remainShowCount = info.winList.Count; currentWin.CancelHide(); for (int i = 0; i < info.winList.Count; ++i) { UIWindow rollbackWin = info.winList[i]; Action preShowHandler = null; preShowHandler = delegate() { currentWin.PreShowEvent -= preShowHandler; --remainShowCount; if (remainShowCount == 0) { bool lastState = m_InRequestRollback; m_InRequestRollback = true; currentWin.Hide(); m_InRequestRollback = lastState; } }; rollbackWin.PreShowEvent += preShowHandler; if (rollbackWin.IsShow()) { preShowHandler(); } else { rollbackWin.Show((object[])rollbackWin.NotifyPopRollback()); } } m_InRequestRollback = false; }
public UpdaterCore(WindowsPatcherConfig windowsPatcherConfig, Process hostProcess, IPatcherTranslation translation) { _windowsPatcherConfig = windowsPatcherConfig; _hostProcess = hostProcess; _environmentManager = new EnvironmentManager(windowsPatcherConfig); _rollbackInfo = new RollbackInfo("rollbackInfo.json") { ApplicationPath = windowsPatcherConfig.ApplicationPath, PatcherConfig = windowsPatcherConfig }; _logger = new Logger(Path.Combine(windowsPatcherConfig.ActionConfig.ProjectId.GetTempDirectory(), "patcher", "log.txt")); Translation = translation; _statusUpdater = new StatusUpdater(Translation); _statusUpdater.StatusUpdated += StatusUpdaterOnStatusUpdated; }
public static void DoPveRollback(ShopInfo shopInfo, Units unit) { RollbackInfo rollbackInfo = shopInfo.RollbackStack.Peek(); if (rollbackInfo != null) { BattleEquipTools_op.ChangeHeroMoney(unit.unique_id, -rollbackInfo._deltaMoney); BattleEquipTools_op.SetHeroItems(unit, rollbackInfo._items); } byte[] msgParam = SerializeHelper.Serialize <RetaMsg>(new RetaMsg { retaCode = 0 }); MobaMessage message = MobaMessageManager.GetMessage(PvpCode.C2P_RevertShop, msgParam, 0f, null); MobaMessageManager.DispatchMsg(message); }
private bool RollBackToLastPartialMatch(ref int exIndex, ref int patIndex) { if (rollBackStack == null || rollBackStack.Count == 0) { return(false); } // restore state up to the last expression variable RollbackInfo info = (RollbackInfo)rollBackStack.Pop(); exIndex = info.exIndex; patIndex = info.patIndex; // clear values of all bound variables starting later than patIndex ClearBoundValues(patIndex); return(true); }
//--------------------------------------------------------------------- public bool IsRollback(string name) { Stack <RollbackInfo> .Enumerator iter = Instance.m_RollbackStack.GetEnumerator(); while (iter.MoveNext()) { RollbackInfo info = iter.Current; for (int index = 0; index < info.winList.Count; ++index) { if (info.winList[index].WindowName == name) { return(true); } } } return(false); }
private void SaveRollBackInfo(int exIndex, int patIndex) { RollbackInfo info = new RollbackInfo(); info.exIndex = exIndex; info.patIndex = patIndex; if (rollBackStack == null) rollBackStack = new Stack<RollbackInfo>(); rollBackStack.Push(info); }
public static bool Match(PassiveExpression expression, Pattern pattern) { bool match = true; Stack rollBackStack = new Stack(); // assume that expression and pattern aren't empty int exIndex = 0, patIndex = 0; while (true) { while (match && patIndex < pattern.Count && exIndex < expression.Count) { object ex = expression[exIndex]; object pat = pattern[patIndex]; bool needRollback = false; // braces can only match itself if (pat is OpeningBrace) { if (ex is OpeningBrace) { exIndex++; patIndex++; continue; } else needRollback = true; } else if (pat is ClosingBrace) { if (ex is ClosingBrace) { exIndex++; patIndex++; continue; } else needRollback = true; } // symbol matches single symbol else if (!(pat is Variable)) { // check for () is redundant because of ex.Equals(pat) if (ex.Equals(pat) && !(ex is StructureBrace)) { exIndex++; patIndex++; continue; } else needRollback = true; } // symbol or term variable matches single symbol else if ((pat is SymbolVariable || pat is TermVariable) && !(ex is StructureBrace)) { Variable var = pat as Variable; if (patIndex == var.FirstOccurance) { var.Value = ex; exIndex++; patIndex++; continue; } else if (ex.Equals(var.Value)) { exIndex++; patIndex++; continue; } else { // symbol don't match the bound variable, // roll back to the last expression variable needRollback = true; } } // term variable matches subexpression in structure braces else if ((pat is TermVariable) && (ex is StructureBrace)) { TermVariable term = pat as TermVariable; // first occurance => copy subexpression if (patIndex == term.FirstOccurance) { if (ex is OpeningBrace) { term.Expression.Add(ex); exIndex++; patIndex++; // extract subexpression within the structure braces int rank = 1; while (exIndex < expression.Count && rank > 0) { ex = expression[exIndex++]; term.Expression.Add(ex); if (ex is OpeningBrace) rank++; else if (ex is ClosingBrace) rank--; } // subexpression with surrounding braces is extracted if (rank == 0) continue; else { // closing structure brace not found => rolling back // in fact, this can only be caused by unmatched braces... needRollback = true; } } else { needRollback = true; } } else // not the first occurance => compare expression { if (CompareExpressions(expression, exIndex, term.Expression)) { exIndex += term.Expression.Count; patIndex++; continue; } else needRollback = true; } } // expression variable can match nothing, symbol(s), // and expression(s) within structure braces else if (pat is ExpressionVariable) { ExpressionVariable var = pat as ExpressionVariable; if (patIndex == var.FirstOccurance) { if (var.Expression == null) { // start with empty expression var.Expression = new PassiveExpression(); RollbackInfo info = new RollbackInfo(); info.exIndex = exIndex; info.patIndex = patIndex; rollBackStack.Push(info); patIndex++; continue; } else { // continue adding terms to expression if (!(ex is StructureBrace)) { var.Expression.Add(ex); RollbackInfo info = new RollbackInfo(); info.exIndex = exIndex + 1; info.patIndex = patIndex; rollBackStack.Push(info); exIndex++; patIndex++; continue; } // handle structure braces, extract subexpression else if (ex is OpeningBrace) { var.Expression.Add(ex); exIndex++; // extract subexpression within the structure braces int rank = 1; while (exIndex < expression.Count && rank > 0) { ex = expression[exIndex++]; var.Expression.Add(ex); if (ex is OpeningBrace) rank++; else if (ex is ClosingBrace) rank--; } // subexpression with surrounding braces is extracted if (rank == 0) continue; else { // closing structure brace not found => rolling back // this can only be caused by unmatched braces => error in compiler needRollback = true; } } else { // extra closing brace ) => roll back needRollback = true; } } } else // not the first occurance, compare expressions { if (CompareExpressions(expression, exIndex, var.Expression)) { exIndex += var.Expression.Count; patIndex++; continue; } else // expression don't match, roll back needRollback = true; } } // if can't find any match, roll back else { needRollback = true; } // roll back to the last expression variable, if needed if (needRollback) { // can't roll back => matching failed if (rollBackStack.Count == 0) { match = false; } else { // restore state up to the last expression variable RollbackInfo info = (RollbackInfo)rollBackStack.Pop(); exIndex = info.exIndex; patIndex = info.patIndex; // clear values of all bound variables starting later than patIndex ClearBoundValues(pattern, patIndex); } } // if (needRollback) } // while() if (match && patIndex >= pattern.Count && exIndex >= expression.Count) return true; // check for special case: expression has ended, but pattern contains a few expression variables // in that case, matching should succeed, with all remaining variables taking empty values if (match && exIndex >= expression.Count && patIndex < pattern.Count) { while (match && patIndex < pattern.Count) { object pat = pattern[patIndex++]; if (!(pat is ExpressionVariable)) { match = false; break; } ExpressionVariable var = (ExpressionVariable)pat; var.Expression = new PassiveExpression(); } if (match && patIndex >= pattern.Count) return true; } // if can roll back, try once more if (rollBackStack.Count == 0) { // nothing to roll back => matching has failed return false; } else { // restore state up to the last expression variable and iterate once more! RollbackInfo info = (RollbackInfo)rollBackStack.Pop(); exIndex = info.exIndex; patIndex = info.patIndex; // clear values of all bound variables starting later than patIndex ClearBoundValues(pattern, patIndex); } } }
public void Rollback(RollbackInfo rollbackInfo) { }
//--------------------------------------------------------------------- private void RequestPushRollback(UIWindow currentWin) { if (m_InRequestRollback) { return; } m_InRequestRollback = true; if (!CanRollback(currentWin)) { m_InRequestRollback = false; return; } if (m_RollbackStack.Count != 0 && m_RollbackStack.Peek().source == currentWin) { m_InRequestRollback = false; return; } List <UIWindow> winList = new List <UIWindow>(); for (int i = 0; i < m_WindowList.Count; ++i) { UIWindow lastWin = m_WindowList[i]; if (lastWin != currentWin && lastWin.IsShow() && !lastWin.IsHiding() && m_RollbackGroupList.Contains(lastWin.windowGroup)) { winList.Add(lastWin); } /* * if (lastWin != currentWin && lastWin.IsShow() && * m_RollbackGroupList.Contains(lastWin.windowGroup)) { * winList.Add(lastWin); * } */ } if (winList.Count != 0) { RollbackInfo info = new RollbackInfo(currentWin, winList); m_RollbackStack.Push(info); Action preShowHandler = null; preShowHandler = delegate() { bool lastState = m_InRequestRollback; m_InRequestRollback = true; currentWin.PreShowEvent -= preShowHandler; for (int i = 0; i < info.winList.Count; ++i) { UIWindow rollbackWin = info.winList[i]; rollbackWin.Hide((object[])rollbackWin.NotifyPushRollback()); } m_InRequestRollback = lastState; }; currentWin.PreShowEvent += preShowHandler; } m_InRequestRollback = false; }