/// <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(); }
/// <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(); }
/// <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); }
/// <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(); }
/// <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; }