Exemplo n.º 1
0
        /// <summary>
        /// Load the configuration from an XmlElement.
        /// </summary>
        /// <param name="root">The element to load from.</param>
        /// <returns>True if successful.</returns>
        public static bool LoadConfig(XmlElement root)
        {
            XmlNode tokenNode = null;

            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.Name == "rowset")
                {
                    XmlNode nameAttr = node.Attributes.GetNamedItem("name");
                    if (nameAttr?.Value == "SSO_Tokens")
                    {
                        // Save the token node to load last, we need to be sure the client_ID and security_key have been loaded.
                        tokenNode = node;
                    }
                    continue;
                }
                switch (node.Name)
                {
                case "language":
                    language = node.InnerText;
                    break;

                case "cachePath":
                    cachePath = node.InnerText;
                    break;

                case "imagePath":
                    imagePath = node.InnerText;
                    break;

                case "typeIconZip":
                    typeIconZip = node.InnerText;
                    break;

                case "renderZip":
                    renderZip = node.InnerText;
                    break;

                case "iconsZip":
                    iconsZip = node.InnerText;
                    break;

                case "apiURL":
                    apiURL = node.InnerText;
                    break;

                case "imageURL":
                    imageURL = node.InnerText;
                    break;

                case "sdeZip":
                    sdeZip = node.InnerText;
                    break;

                case "ssoClientID":
                    sso_ClientID = node.InnerText;
                    break;

                case "ssoRedirectURI":
                    sso_RedirectURI = node.InnerText;
                    break;

                case "ssoSecurityKey":
                    sso_SecurityKey = node.InnerText;
                    break;

                case "ssoScopes":
                    sso_Scopes = node.InnerText;
                    break;
                }
            }
            // Now we can load the tokens.
            if (tokenNode != null)
            {
                SSO.LoadTokens(tokenNode);
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a xml node containing the EVE-All-API configuration inforation.
        /// </summary>
        /// <param name="doc">The document to create the node for.</param>
        /// <returns>The save node.</returns>
        public static XmlNode GetSave(XmlDocument doc)
        {
            // Create the config root.
            XmlNode root = doc.CreateElement("EVE-All-API");
            // Save SSO tokens.
            XmlElement tokens = SSO.GetTokenNode(doc);

            root.AppendChild(tokens);
            // Save language.
            xmlUtils.newElement(root, "language", language);
            // Save paths.
            if (!string.IsNullOrWhiteSpace(cachePath))
            {
                xmlUtils.newElement(root, "cachePath", cachePath);
            }
            if (!string.IsNullOrWhiteSpace(imagePath))
            {
                xmlUtils.newElement(root, "imagePath", imagePath);
            }
            if (!string.IsNullOrWhiteSpace(typeIconZip))
            {
                xmlUtils.newElement(root, "typeIconZip", typeIconZip);
            }
            if (!string.IsNullOrWhiteSpace(renderZip))
            {
                xmlUtils.newElement(root, "renderZip", renderZip);
            }
            if (!string.IsNullOrWhiteSpace(iconsZip))
            {
                xmlUtils.newElement(root, "iconsZip", iconsZip);
            }
            if (!string.IsNullOrWhiteSpace(apiURL))
            {
                xmlUtils.newElement(root, "apiURL", apiURL);
            }
            if (!string.IsNullOrWhiteSpace(imageURL))
            {
                xmlUtils.newElement(root, "imageURL", imageURL);
            }
            if (!string.IsNullOrWhiteSpace(sdeZip))
            {
                xmlUtils.newElement(root, "sdeZip", sdeZip);
            }
            if (!string.IsNullOrWhiteSpace(sso_ClientID))
            {
                xmlUtils.newElement(root, "ssoClientID", sso_ClientID);
            }
            if (!string.IsNullOrWhiteSpace(sso_RedirectURI))
            {
                xmlUtils.newElement(root, "ssoRedirectURI", sso_RedirectURI);
            }
            if (!string.IsNullOrWhiteSpace(sso_SecurityKey))
            {
                xmlUtils.newElement(root, "ssoSecurityKey", sso_SecurityKey);
            }
            if (!string.IsNullOrWhiteSpace(sso_Scopes))
            {
                xmlUtils.newElement(root, "ssoScopes", sso_Scopes);
            }
            return(root);
        }