Пример #1
0
        /// <summary>
        /// 异步检查更新、更新信息返回到checkDelegate委托方法
        /// </summary>
        /// <param name="version">本程序版本</param>
        /// <param name="checkDelegate">检查结果回调</param>
        /// <returns></returns>
        public async Task CheckUpdate(string version, CheckUpdateDelegate checkDelegate)
        {
            await Task.Run(() =>
            {
                string updateUrl      = defaultUpdateUrl;
                UpdateInfo updateInfo = new UpdateInfo();

                if (settings != null && ((JObject)settings).Count > 0 && ((JObject)settings).ContainsKey("update"))
                {
                    updateUrl = ((JToken)settings.update).ToString().Length > 7 ? settings.update : updateUrl;
                }

                string newver          = "0";
                string data            = WebRequestHelper.HttpGet(updateUrl);
                updateInfo.downloadUrl = GeneralHelper.FindBetweenString(data, "[dl>", "<dl]").Trim();
                updateInfo.newVer      = GeneralHelper.FindBetweenString(data, "[ver>", "<ver]");
                newver  = updateInfo.newVer.Replace(".", string.Empty);
                version = version.Replace(".", string.Empty);
                try
                {
                    if (Convert.ToUInt32(newver) > Convert.ToUInt32(version) && updateInfo.downloadUrl.Length > 7)
                    {
                        updateInfo.haveUpdate = true;
                        updateInfo.updateMsg  = GeneralHelper.FindBetweenString(data, "[msg>", "<msg]");
                    }
                }
                catch { }
                checkDelegate(updateInfo);
            });
        }
Пример #2
0
	private static extern void _CheckUpdateWithDelegate(CheckUpdateDelegate checkUpdateDelegate);
Пример #3
0
 public static void CheckUpdateWithCallBack(CheckUpdateDelegate checkUpdateCallBack)
 {
     checkUpdate = checkUpdateCallBack;
     _CheckUpdateWithDelegate(_checkUpdateDelegate);
 }
Пример #4
0
 private static extern void _CheckUpdateWithDelegate(CheckUpdateDelegate checkUpdateDelegate);
Пример #5
0
 public static void CheckUpdateWithCallBack(CheckUpdateDelegate checkUpdateCallBack)
 {
     checkUpdate = checkUpdateCallBack;
     _CheckUpdateWithDelegate(_checkUpdateDelegate);
 }