コード例 #1
0
ファイル: Updater.cs プロジェクト: blint96/G2O_Launcher
        /// <summary>
        ///     Starts a asynchronous server request to find out if the is a newer version that the currently used one.
        /// </summary>
        public void Check()
        {
            G2OVersion version;

            using (G2OProxy proxy = new G2OProxy())
            {
                version = proxy.Version();
            }

            using (WebClient webClient = new WebClient())
            {
                string uriString = UpdateUri;
                webClient.UploadStringCompleted += this.UpdateUploadStringCompleted;
                try
                {
                    var post = new UpdatePost()
                    {
                        major = version.Major,
                        minor = version.Minor,
                        patch = version.Patch,
                        build = version.Build
                    };
                    string data = JsonConvert.SerializeObject(post);
                    webClient.UploadStringAsync(new Uri(uriString), "POST", data);
                }
                catch (WebException ex)
                {
                    this.ErrorOccured?.Invoke(this, new UpdateErrorEventArgs(ex.Message));
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Gets the current client version and writes it into the <see cref="VersionText"/> property.
 /// </summary>
 private void UpdateVersionText()
 {
     using (G2OProxy proxy = new G2OProxy())
     {
         this.VersionText = proxy.Version().ToString();
     }
 }