Beispiel #1
0
        /// <summary>
        /// When a web request completes, triggers the handler for the next updater.
        /// </summary>
        /// <param name="request">The YAML web request data.</param>
        /// <param name="mod">The mod that needs to be checked.</param>
        private void OnRequestFinished(UnityWebRequest request, Mod mod)
        {
            ModVersionCheckResults result = null;

            if (request.result == UnityWebRequest.Result.Success)
            {
                // Parse the text
                var modInfo = YamlIO.Parse <Mod.PackagedModInfo>(request.downloadHandler.
                                                                 text, default);
                string newVersion = modInfo?.version;
                if (modInfo != null && !string.IsNullOrEmpty(newVersion))
                {
                    string curVersion = PVersionCheck.GetCurrentVersion(mod);
#if DEBUG
                    PUtil.LogDebug("Current version: {0} New YAML version: {1}".F(
                                       curVersion, newVersion));
#endif
                    result = new ModVersionCheckResults(mod.staticID, newVersion !=
                                                        curVersion, newVersion);
                }
            }
            request.Dispose();
            OnVersionCheckCompleted?.Invoke(result);
        }
        /// <summary>
        /// When a web request completes, triggers the handler for the next updater.
        /// </summary>
        /// <param name="request">The JSON web request data.</param>
        /// <param name="mod">The mod that needs to be checked.</param>
        private void OnRequestFinished(UnityWebRequest request, Mod mod)
        {
            ModVersionCheckResults result = null;

            if (request.result == UnityWebRequest.Result.Success)
            {
                // Parse the text
                ModVersions versions;
                using (var reader = new StreamReader(new MemoryStream(request.
                                                                      downloadHandler.data))) {
                    versions = new JsonSerializer()
                    {
                        MaxDepth = 4, DateTimeZoneHandling = DateTimeZoneHandling.Utc,
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    }.Deserialize <ModVersions>(new JsonTextReader(reader));
                }
                if (versions != null)
                {
                    result = ParseModVersion(mod, versions);
                }
            }
            request.Dispose();
            OnVersionCheckCompleted?.Invoke(result);
        }