Пример #1
0
        public override void OnActivate()
        {
            _modInfo.SetText(_info);
            _uITextPanel.SetText(Language.GetTextValue("tModLoader.ModInfoHeader") + _modDisplayName, 0.8f, true);
            if (_loadFromWeb)
            {
                _modInfo.Append(_loaderElement);
                _loading = true;
                _ready   = false;

                _cts = new CancellationTokenSource();

                Task.Factory.StartNew(() => {
                    try {
                        ServicePointManager.Expect100Continue = false;
                        const string url = "http://javid.ddns.net/tModLoader/moddescription.php";
                        var values       = new NameValueCollection {
                            { "modname", _modName }
                        };
                        using (WebClient client = new WebClient()) {
                            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, policyErrors) => policyErrors == SslPolicyErrors.None;
                            client.UploadValuesCompleted += ReceiveModInfo;
                            client.UploadValuesAsync(new Uri(url), "POST", values);
                        }
                    }
                    catch (Exception e) {
                        UIModBrowser.LogModBrowserException(e);
                    }
                }, _cts.Token);
            }
            else
            {
                _loading = false;
                _ready   = true;
            }
        }