示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateClient"/> class.
        /// </summary>
        /// <param name="settings">The <see cref="UpdateClientSettings"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception>
        public UpdateClient(UpdateClientSettings settings)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            // Get a read-only deep copy of the settings so that nobody can accidentally change it while in use, including us
            _settings = settings.ReadOnlyDeepCopy();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateClient"/> class.
        /// </summary>
        /// <param name="settings">The <see cref="UpdateClientSettings"/>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception>
        public UpdateClient(UpdateClientSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            // Get a read-only deep copy of the settings so that nobody can accidentally change it while in use, including us
            _settings = settings.ReadOnlyDeepCopy();
        }
示例#3
0
        /// <summary>
        /// Creates a deep copy of this instance.
        /// </summary>
        /// <returns>A deep copy of this instance.</returns>
        public UpdateClientSettings DeepCopy()
        {
            var ret = new UpdateClientSettings
            {
                LocalFileServerPath   = LocalFileServerPath,
                LocalMasterServerPath = LocalMasterServerPath,
                TempPath   = TempPath,
                TargetPath = TargetPath,
                OfflineFileReplacerCreator = OfflineFileReplacerCreator,
                OfflineFileReplacerPath    = OfflineFileReplacerPath,
                VersionFilePath            = VersionFilePath,
                ResetAppPath = ResetAppPath
            };

            return(ret);
        }
示例#4
0
文件: MainForm.cs 项目: wtfcolt/game
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data. </param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var targetDir = Application.StartupPath;
            var settingsPath = PathHelper.CombineDifferentPaths(Application.StartupPath, "UpdaterSettings");
            var resetAppPath = Application.ExecutablePath;
            var settings = new UpdateClientSettings(targetDir, settingsPath, resetAppPath);

            _uc = new UpdateClient(settings);
            _uc.StateChanged += _uc_StateChanged;
            _uc.LiveVersionFound += _uc_LiveVersionFound;
            _uc.FileDownloaded += _uc_FileDownloaded;
            _uc.FileDownloadFailed += _uc_FileDownloadFailed;
            _uc.FileMoveFailed += _uc_FileMoveFailed;
            _uc.MasterServerReaderError += _uc_MasterServerReaderError;
            _uc.IsRunningChanged += _uc_IsRunningChanged;
            _uc.HasErrorsChanged += _uc_HasErrorsChanged;

            _uc.Start();
        }
示例#5
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data. </param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var targetDir    = Application.StartupPath;
            var settingsPath = PathHelper.CombineDifferentPaths(Application.StartupPath, "UpdaterSettings");
            var resetAppPath = Application.ExecutablePath;
            var settings     = new UpdateClientSettings(targetDir, settingsPath, resetAppPath);

            _uc = new UpdateClient(settings);
            _uc.StateChanged            += _uc_StateChanged;
            _uc.LiveVersionFound        += _uc_LiveVersionFound;
            _uc.FileDownloaded          += _uc_FileDownloaded;
            _uc.FileDownloadFailed      += _uc_FileDownloadFailed;
            _uc.FileMoveFailed          += _uc_FileMoveFailed;
            _uc.MasterServerReaderError += _uc_MasterServerReaderError;
            _uc.IsRunningChanged        += _uc_IsRunningChanged;
            _uc.HasErrorsChanged        += _uc_HasErrorsChanged;

            _uc.Start();
        }
示例#6
0
        /// <summary>
        /// Creates a deep copy of this instance.
        /// </summary>
        /// <returns>A deep copy of this instance.</returns>
        public UpdateClientSettings DeepCopy()
        {
            var ret = new UpdateClientSettings
            {
                LocalFileServerPath = LocalFileServerPath,
                LocalMasterServerPath = LocalMasterServerPath,
                TempPath = TempPath,
                TargetPath = TargetPath,
                OfflineFileReplacerCreator = OfflineFileReplacerCreator,
                OfflineFileReplacerPath = OfflineFileReplacerPath,
                VersionFilePath = VersionFilePath,
                ResetAppPath = ResetAppPath
            };

            return ret;
        }