Exemple #1
0
        public void TestInstaller(string installCode, string installerCode)
        {
            var installScheme = GithubSchemeDecoder.DecodeShort(installCode);

            this.FetchInstallsRegistry();
            var install = Installs.FirstOrDefault(_ => _.RepositoryName == installScheme.Name && _.AuthorName == installScheme.Owner);

            if (install == null)
            {
                Logger.LogProblem("No install found matching: " + installCode);
                return;
            }

            var regex = new Regex("(?<type>[^\\.]*)\\.(?<method>[^\\.]*)");

            var mathc = regex.Match(installerCode);

            if (!mathc.Success)
            {
                Logger.LogProblem("Code should be in format: <InstallerType>.<Method>");
                return;
            }

            var typeName   = mathc.Groups["type"].Value;
            var methodName = mathc.Groups["method"].Value;

            var type =
                AppDomain.CurrentDomain.GetAssemblies()
                .Select(_ => _.GetType(typeName))
                .FirstOrDefault(_ => _ != null);

            if (type == null)
            {
                Logger.LogProblem("Installer type not found: " + typeName);
                return;
            }

            var method = type.GetMethod(methodName);

            if (method == null)
            {
                Logger.LogProblem("Method not found: " + methodName);
                return;
            }

            var result = false;

            var installer = (Installer)Activator.CreateInstance(type, new object[] { CliFrontend });

            result = (bool)method.Invoke(installer, new object[] { install });

            if (result)
            {
                Logger.Log("Install Test Finished");
            }
            else
            {
                Logger.Log("Install Not Finished");
            }
        }
Exemple #2
0
        public void Update(Install install)
        {
            var update = new Updater(this, this, GithubApi, Logger);

            update.Update(install);


            var reimports = Installs.Where(i => i.ConfigData.RequiresFullReimport && !i.InstallFinalized).ToArray();

            if (reimports.Any())
            {
                var msg = "Following packages require full reimport to function properly:\n";
                foreach (var reimport in reimports)
                {
                    msg += reimport.ToShortString() + "\n";
                }

                ThreadingUtils.DispatchOnMainThread(() =>
                {
                    if (EditorUtility.DisplayDialog("Koinonia", msg, "Ok", "No, I'll do it myself"))
                    {
                        EditorApplication.ExecuteMenuItem("Assets/Reimport All");
                    }
                    else
                    {
                        AssetDatabase.Refresh();
                    }
                });
            }
            else
            {
                ThreadingUtils.DispatchOnMainThread(AssetDatabase.Refresh);
            }
        }
Exemple #3
0
        private async void LoadClient()
        {
            bool   installKeyPresent = false;
            string ik;

            ik = MednaNetSettings.GetInstallKey();
            if (ik != null && ik.Trim() != "")
            {
                installKeyPresent = true;
                InstallKey        = ik;
            }

            // Instantiate client
            if (installKeyPresent == true)
            {
                Client = new Client(EndPointAddress, EndPointPort, ik);
            }
            else
            {
                Client = new Client(EndPointAddress, EndPointPort);
            }


            // get the current install object from the API
            if (installKeyPresent == true)
            {
                try { CurrentInstall = await Client.Install.GetCurrentInstall(InstallKey); }
                catch (Exception ex) { APIDisconnected(ex); return; }
            }


            if (installKeyPresent == false)
            {
                try { CurrentInstall = await Client.Install.GetCurrentInstall(""); }
                catch (Exception ex) { APIDisconnected(ex); return; }


                InstallKey = CurrentInstall.code;
                MednaNetSettings.SetInstallKey(InstallKey);
            }

            isConnected = true;

            DoPoll();

            // start the timer
            Timer.Start();
        }