/// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private XmlNode GetValueNode(Setting node)
        {
            XmlNode xmlNode = _xml.SelectSingleNode("/CharacterSettings/" + node.ToString());

            try
            {
                if (xmlNode == null)
                {
                    XmlNode parent = _xml.SelectSingleNode("/CharacterSettings");
                    xmlNode = _xml.CreateElement(node.ToString());
                    parent.AppendChild(xmlNode);
                }
                if (xmlNode.FirstChild == null)
                {
                    XmlText xmlValue = _xml.CreateTextNode(GetDefaultValue(node));
                    xmlNode.AppendChild(xmlValue);
                }
            }
            catch (Exception ex)
            {
                EMMASettingsException emmaEx = new EMMASettingsException(ExceptionSeverity.Error,
                    "Error getting value from character settings file for " + node.ToString(), ex);
            }

            return xmlNode;
        }
        /// <summary>
        /// Internal method to set the value of a specified setting in the in-memory settings file.
        /// If the specified setting does not exist then it is added.
        /// </summary>
        /// <param name="node">The setting to set the value of</param>
        /// <param name="value">The value to assign to the specified setting</param>
        private void SetValue(Setting node, string value)
        {
            XmlNode xmlNode = _xml.SelectSingleNode("/CharacterSettings/" + node.ToString());

            try
            {
                if (xmlNode == null)
                {
                    XmlNode parent = _xml.SelectSingleNode("/CharacterSettings");
                    xmlNode = _xml.CreateElement(node.ToString());
                    parent.AppendChild(xmlNode);
                }
                if (xmlNode.FirstChild == null)
                {
                    XmlText xmlValue = _xml.CreateTextNode(value);
                    xmlNode.AppendChild(xmlValue);
                }
                else
                {
                    xmlNode.FirstChild.Value = value;
                }
                _changed = true;
                if (SettingsUpdated != null)
                {
                    SettingsUpdated(this, null);
                }
            }
            catch (Exception ex)
            {
                EMMASettingsException emmaEx = new EMMASettingsException(ExceptionSeverity.Error,
                    "Error setting value in character settings file for " + node.ToString(), ex);
            }
        }
예제 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private XmlNode GetValueNode(string node)
        {
            XmlNode xmlNode = _xml.SelectSingleNode("/UserSettings/" + node);

            try
            {
                if (xmlNode == null)
                {
                    XmlNode parent = _xml.SelectSingleNode("/UserSettings");
                    xmlNode = _xml.CreateElement(node);
                    parent.AppendChild(xmlNode);
                }
                if (xmlNode.FirstChild == null)
                {
                    Setting setting = Setting.APIAssetUpdatePeriod;
                    bool createDefault = false;
                    try
                    {
                        setting = (Setting)Enum.Parse(typeof(Setting), node);
                        createDefault = true;
                    }
                    catch { }
                    if (createDefault)
                    {
                        XmlText xmlValue = _xml.CreateTextNode(GetDefaultValue(setting));
                        xmlNode.AppendChild(xmlValue);
                    }
                }
            }
            catch (Exception ex)
            {
                EMMASettingsException emmaEx = new EMMASettingsException(ExceptionSeverity.Error,
                    "Error getting value from user settings file for " + node, ex);
            }

            return xmlNode;
        }