private static JSONObject LoadProjectManifest()
        {
            string     manifestString = File.ReadAllText(RegistrySettings.Instance().ProjectManifestPath);
            JSONObject manifestJson   = JSONNode.Parse(manifestString).AsObject;

            return(manifestJson);
        }
 private void OnAddButtonClicked()
 {
     ManifestUtils.AddRegistry(RegistrySettings.Instance().Registry);
     ShowPackageManager();
     UpdateAddButtonEnabled();
     UpdateRemoveButtonEnabled();
     UpdateAllStatus();
 }
 private void OnRemoveButtonClicked()
 {
     ManifestUtils.RemoveRegistry(RegistrySettings.Instance().Registry.Name);
     RegistrySettings.Instance().SetAutoCheckEnabled(false);
     AutoCheckToggle.value = false;
     UpdateAddButtonEnabled();
     UpdateRemoveButtonEnabled();
     UpdateAllStatus();
 }
        private void UpdateRegistryStatus()
        {
            RegistryStatusLabel.RemoveFromClassList(StatusSuccessClass);
            RegistryStatusLabel.RemoveFromClassList(StatusErrorClass);

            if (ManifestUtils.CheckRegistryExists(RegistrySettings.Instance().Registry))
            {
                RegistryStatusLabel.AddToClassList(StatusSuccessClass);
                RegistryStatusLabel.text = RegistryStatusSuccessString;
            }
            else
            {
                RegistryStatusLabel.AddToClassList(StatusErrorClass);
                RegistryStatusLabel.text = RegistryStatusErrorString;
            }
        }
        private bool CheckRegistryConnection()
        {
            string host = RegistrySettings.Instance().RegistryHost;
            int    port = RegistrySettings.Instance().RegistryPort;

            try
            {
                using (TcpClient client = new TcpClient())
                {
                    client.Connect(host, port);
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
        private void OnEnable()
        {
            rootVisualElement.styleSheets.Add(UIStyle);
            UITemplate.CloneTree(rootVisualElement);

            Label registryUrlLabel = rootVisualElement.Query <Label>("RegistryUrlLabel").First();

            registryUrlLabel.text = RegistrySettings.Instance().Registry.Url;

            Label  registryScopesLabel = rootVisualElement.Query <Label>("RegistryScopesLabel").First();
            string strScopes           = "";

            foreach (string strScope in RegistrySettings.Instance().Registry.Scopes)
            {
                if (!string.IsNullOrEmpty(strScopes))
                {
                    strScopes += ", ";
                }

                strScopes += strScope;
            }

            registryScopesLabel.text = strScopes;

            AutoCheckToggle = rootVisualElement.Query <Toggle>("AutoCheck").First();
            AutoCheckToggle.RegisterCallback <MouseUpEvent>(OnAutoCheckToggled);
            AutoCheckToggle.value = RegistrySettings.Instance().AutoCheckEnabled;

            RegistryStatusLabel   = rootVisualElement.Query <Label>("RegistryStatusLabel").First();
            ConnectionStatusLabel = rootVisualElement.Query <Label>("ConnectionStatusLabel").First();

            AddButton = rootVisualElement.Query <Button>("Add").First();
            AddButton.clickable.clicked += OnAddButtonClicked;
            UpdateAddButtonEnabled();

            RemoveButton = rootVisualElement.Query <Button>("Remove").First();
            RemoveButton.clickable.clicked += OnRemoveButtonClicked;
            UpdateRemoveButtonEnabled();

            Button closeButton = rootVisualElement.Query <Button>("Close").First();

            closeButton.clickable.clicked += OnCloseButtonClicked;
        }
 private void UpdateRemoveButtonEnabled()
 {
     RemoveButton.SetEnabled(ManifestUtils.CheckRegistryExists(RegistrySettings.Instance().Registry));
 }
 private void OnAutoCheckToggled(MouseUpEvent mouseUpEvent)
 {
     RegistrySettings.Instance().SetAutoCheckEnabled(AutoCheckToggle.value);
 }
        private static void Save(JSONObject newJson)
        {
            string jsonString = newJson.ToString(JSON_INDENT_SPACE_COUNT);

            File.WriteAllText(RegistrySettings.Instance().ProjectManifestPath, jsonString);
        }