Beispiel #1
0
        public void TestRegistryManagerController()
        {
            Assert.AreEqual(1, RegistryManagerController.AllWrappedRegistries.Count);

            var u = new Uri(Path.GetFullPath(Path.Combine(TestData.PATH,
                                                          "registry2/registry.xml")));

            Assert.AreEqual(ResponseCode.REGISTRY_ADDED,
                            RegistryManagerController.AddRegistry(u));
            Assert.AreEqual(2, RegistryManagerController.AllWrappedRegistries.Count);

            // Cannot add same uri.
            Assert.AreEqual(ResponseCode.REGISTRY_ALREADY_PRESENT,
                            RegistryManagerController.AddRegistry(u));

            // loading the database again should still be in same state
            RegistryManagerController.LoadRegistryDatabase();
            Assert.AreEqual(2, RegistryManagerController.AllWrappedRegistries.Count);

            Assert.AreEqual(ResponseCode.REGISTRY_REMOVED,
                            RegistryManagerController.RemoveRegistry(u));

            // Can't remove it a second time it won't be there.
            Assert.AreEqual(ResponseCode.REGISTRY_NOT_FOUND,
                            RegistryManagerController.RemoveRegistry(u));
        }
Beispiel #2
0
        /// <summary>
        /// Update override method called by Unity editor. The update cycle looks
        /// for any action events that were generated in the OnGUI method by the
        /// user and takes action on those events.
        /// </summary>
        void Update()
        {
            if (registryDataDirty)
            {
                LoggingController.Log("plugin data marked dirty - refreshing...");
                registryDataDirty = false;
                RegistryManagerController.RefreshRegistryCache();
                EditorUtility.SetDirty(this);
            }

            while (installRegistry.Count > 0)
            {
                var regUriStr = installRegistry.Pop();
                try {
                    ResponseCode rc = RegistryManagerController.AddRegistry(new Uri(regUriStr));
                    if (ResponseCode.REGISTRY_ADDED == rc)
                    {
                        registryDataDirty = true;
                    }
                    else if (ResponseCode.REGISTRY_ALREADY_PRESENT == rc)
                    {
                        EditorUtility.DisplayDialog("Registry Already Present",
                                                    "The registry was NOT added since it" +
                                                    "is already known.",
                                                    "Ok");
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Registry Location Not Valid",
                                                    string.Format(
                                                        "The registry cannot be added. An " +
                                                        "error has occured using the provided " +
                                                        "location.\n\n{0}", rc),
                                                    "Ok");
                    }
                } catch (Exception e) {
                    // failure - bad data
                    EditorUtility.DisplayDialog("Registry Location Processing Error",
                                                string.Format("A processing exception was " +
                                                              "generated while trying to add {0}." +
                                                              "\n\n{1}", regUriStr, e),
                                                "Ok");
                }
            }

            while (uninstallRegistry.Count > 0)
            {
                var regUriStr = uninstallRegistry.Pop();
                if (EditorUtility.DisplayDialog("Confirm Delete Registry",
                                                "Are you sure you want to delete the registry?",
                                                "Yes Delete It!",
                                                "Cancel"))
                {
                    ResponseCode rc = RegistryManagerController
                                      .RemoveRegistry(new Uri(regUriStr));
                    registryDataDirty = true;
                    if (ResponseCode.REGISTRY_NOT_FOUND == rc)
                    {
                        EditorUtility.DisplayDialog("Registry Not Found!",
                                                    "There was a problem while trying to " +
                                                    "remove the registry. It was not " +
                                                    "found when we tried to remove it."
                                                    , "Ok");
                    }
                }
            }
        }