示例#1
0
        /// <summary>
        /// process the update depending on forceUpdate and AutoUpdate setting
        /// </summary>
        /// <param name="handler">updatehandler for updating</param>
        /// <param name="forceUpdate">should the update get forced?</param>
        /// <returns>is all succeeds?</returns>
        public bool ProcessUpdate(Interfaces.IUpdateHandler handler, bool forceUpdate)
        {
            if (!_initialized) throw new Exceptions.UpdaterNotInitializedException();

            Structures.Configuration configuration = Configuration();

            if (System.IO.Directory.Exists(configuration.UpdateDirectory))
                System.IO.Directory.Delete(configuration.UpdateDirectory, true);

            if (!handler.RetriveProjectInformations(configuration)) return false;
            if (!handler.IsUpdateRequired(configuration, forceUpdate)) return true;
            if (!handler.FetchFileList(configuration)) return false;
            if (!handler.RehashDownload(configuration)) return false;
            if (!handler.DownloadUpdate(configuration)) return false;

            while (WebDownloader.Instance.Downloading) { }

            if (!handler.RehashUpdate(configuration, _defaultConfigurationName)) return false;

            configuration.CurrentVersion = handler.GetNewVersionNumber();
            Configuration(configuration);

            return handler.StopApplication(configuration);
        }