/// <summary> /// Set Proxy Information on WebRequest. /// </summary> /// <param name="request">Makes a request to a Uniform Resource Identifier (URI).</param> private void SetProxy(IWebRequest request) { Debug.Assert(request != null); IWebProxy proxy = _prefs.GetWebProxy(); if (proxy != null) { request.Proxy = proxy; } // Don't set request.Proxy = null - Issue 49 }
/// <summary> /// Downloads the project information. /// </summary> /// <remarks>Access to the Download method is synchronized.</remarks> public void Download(Stream stream, IProgress <ProgressInfo> progress) { IWebOperation httpWebOperation = WebOperation.Create(_prefs.Get <string>(Preference.ProjectDownloadUrl)); if (progress != null) { httpWebOperation.ProgressChanged += (sender, e) => { int progressPercentage = Convert.ToInt32(e.Length / (double)e.TotalLength * 100); string message = String.Format(CultureInfo.CurrentCulture, "Downloading {0} of {1} bytes...", e.Length, e.TotalLength); progress.Report(new ProgressInfo(progressPercentage, message)); }; } httpWebOperation.WebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); httpWebOperation.WebRequest.Proxy = _prefs.GetWebProxy(); httpWebOperation.Download(stream); }
public void CheckForUpdate(bool userInvoked) { if (Owner == null) { throw new InvalidOperationException("Owner property cannot be null."); } if (CheckInProgress) { throw new InvalidOperationException("Update check already in progress."); } CheckInProgress = true; // set globals _userInvoked = userInvoked; _proxy = _prefs.GetWebProxy(); Func <ApplicationUpdate> func = DoCheckForUpdate; func.BeginInvoke(CheckForUpdateCallback, func); }