예제 #1
0
 protected virtual void OnPatchFailed(object sender, PatchFailedEventArgs e)
 {
     PatchFailed?.Invoke(sender, e);
 }
예제 #2
0
        private void InitializePatcher()
        {
            if (m_patcher != null)
            {
                return;
            }

            m_patcher = SPTUtils.CreatePatcher(RootPath, VersionInfoURL).CheckForMultipleRunningInstances(CheckForMultipleRunningInstances).
                        UseRepairPatch(UseRepairPatch).UseIncrementalPatch(UseIncrementalPatch).UseInstallerPatch(UseInstallerPatch).
                        VerifyFilesOnServer(VerifyFilesOnServer).SilentMode(SilentMode).LogProgress(LogProgress).LogToFile(LogToFile);

            if (!string.IsNullOrEmpty(VersionInfoRSA))
            {
                m_patcher.UseVersionInfoVerifier(( ref string xml ) => XMLSigner.VerifyXMLContents(xml, VersionInfoRSA));
            }

            if (!string.IsNullOrEmpty(PatchInfoRSA))
            {
                m_patcher.UsePatchInfoVerifier(( ref string xml ) => XMLSigner.VerifyXMLContents(xml, PatchInfoRSA));
            }

            PatcherListener listener = new PatcherListener();

            listener.OnStart += () =>
            {
                if (m_patcher.Operation == PatchOperation.CheckingForUpdates)
                {
                    CheckForUpdatesStarted.Invoke();
                }
                else if (m_patcher.Operation == PatchOperation.Patching || m_patcher.Operation == PatchOperation.SelfPatching)
                {
                    PatchStarted.Invoke();
                }
            };
            listener.OnLogReceived += (log) =>
            {
                LogReceived.Invoke(log);

                if (LogToConsole)
                {
                    Debug.Log(log);
                }
            };
            listener.OnProgressChanged += (progress) =>
            {
                CurrentProgressPercentageChanged.Invoke(progress.Percentage);
                CurrentProgressTextChanged.Invoke(progress.ProgressInfo);
            };
            listener.OnOverallProgressChanged += (progress) =>
            {
                OverallProgressPercentageChanged.Invoke(progress.Percentage);
                OverallProgressTextChanged.Invoke(progress.ProgressInfo);
            };
            listener.OnPatchStageChanged  += PatchStageChanged.Invoke;
            listener.OnPatchMethodChanged += PatchMethodChanged.Invoke;
            listener.OnVersionInfoFetched += (versionInfo) =>
            {
                for (int i = 0; i < AdditionalIgnoredPaths.Length; i++)
                {
                    if (!string.IsNullOrEmpty(AdditionalIgnoredPaths[i]))
                    {
                        versionInfo.AddIgnoredPath(AdditionalIgnoredPaths[i]);
                    }
                }

                VersionInfoFetched.Invoke(versionInfo);
            };
            listener.OnVersionFetched += (currentVersion, newVersion) =>
            {
                CurrentVersionDetermined.Invoke(currentVersion);
                NewVersionDetermined.Invoke(newVersion);
            };
            listener.OnFinish += () =>
            {
                if (m_patcher.Operation == PatchOperation.CheckingForUpdates)
                {
                    if (m_patcher.Result == PatchResult.AlreadyUpToDate)
                    {
                        AppIsUpToDate.Invoke();
                    }
                    else if (m_patcher.Result == PatchResult.Success)
                    {
                        UpdateAvailable.Invoke();
                    }
                    else
                    {
                        CheckForUpdatesFailed.Invoke(m_patcher.FailDetails);

                        if (LogToConsole)
                        {
                            Debug.LogError(m_patcher.FailDetails);
                        }
                    }
                }
                else if (m_patcher.Operation == PatchOperation.Patching || m_patcher.Operation == PatchOperation.SelfPatching)
                {
                    if (m_patcher.Result == PatchResult.AlreadyUpToDate)
                    {
                        AppIsUpToDate.Invoke();
                    }
                    else if (m_patcher.Result == PatchResult.Success)
                    {
                        PatchSuccessful.Invoke();

                        if (m_patcher.Operation == PatchOperation.Patching)
                        {
                            CurrentVersionDetermined.Invoke(m_patcher.NewVersion);
                        }
                    }
                    else
                    {
                        PatchFailed.Invoke(m_patcher.FailDetails);

                        if (LogToConsole)
                        {
                            Debug.LogError(m_patcher.FailDetails);
                        }
                    }
                }
                else
                {
                    if (m_patcher.Result == PatchResult.AlreadyUpToDate)
                    {
                        AppIsUpToDate.Invoke();
                    }
                    else if (m_patcher.Result == PatchResult.Failed)
                    {
                        SelfPatchingFailed.Invoke(m_patcher.FailDetails);

                        if (LogToConsole)
                        {
                            Debug.LogError(m_patcher.FailDetails);
                        }
                    }
                }
            };

            m_patcher.SetListener(listener);
        }
예제 #3
0
        public virtual void Run(ModuleDefinition moduleDefinition)
        {
            var eventArgs = new PatchFailedEventArgs(Name, new Exception("This patch requires both source and target modules."));

            PatchFailed?.Invoke(this, eventArgs);
        }