Пример #1
0
        /// <summary>
        /// Call this method to choose a branch
        /// </summary>
        /// <remarks>
        /// This method should be called when a branch happens, otherwise An InvalidAccessException will be raised
        /// </remarks>
        /// <param name="branchName">The name of the branch</param>
        /// <exception cref="InvalidAccessException">An InvalidAccessException will be thrown if this method
        /// is not called on branch happens</exception>
        public void SelectBranch(string branchName)
        {
            if (CheckActionRunning())
            {
                return;
            }
            if (!isBranching)
            {
                throw new InvalidAccessException("Nova: SelectBranch() should only be called when a branch happens.");
            }

            state = State.Normal;
            var selectedBranchInfo = currentNode.GetAllBranches().First(x => x.name == branchName);
            var nextNode           = currentNode.GetNext(branchName);

            if (!checkpointManager.IsReached(currentNode.name, branchName, variables.hash))
            {
                // tell the checkpoint manager a branch has been selected
                checkpointManager.SetReached(currentNode.name, branchName, variables);
            }

            BranchSelected?.Invoke(new BranchSelectedData(selectedBranchInfo));

            MoveToNextNode(nextNode);
        }
Пример #2
0
 private void SaveBranch()
 {
     if (BranchSelected == CurrentChromeInfo?.Branch)
     {
         return;
     }
     if (!string.IsNullOrEmpty(SelectedPath) && HasWriteAccess(SelectedPath))
     {
         File.WriteAllText($"{SelectedPath}\\branch", BranchSelected.ToString());
     }
     else if (File.Exists($"{SelectedPath}\\GreenChrome.ini"))
     {
         var ini = new Ini($"{SelectedPath}\\GreenChrome.ini");
         ini.Write("检查版本", BranchSelected.ToString(), "检查更新");
     }
 }