コード例 #1
0
        /// <summary>
        /// Its machine specific, store as an element of the machine name node,
        /// creating a new machine name node if one doesnt exist.
        /// </summary>
        private void CreateLocalValue(SettingsPropertyValue propVal)
        {
            XmlElement machineNode;

            try
            {
                machineNode = (XmlElement)SettingsXml.SelectSingleNode(
                    SettingsRootName + "/" + _localMachineName);
            }
            catch (Exception)
            {
                machineNode = SettingsXml.CreateElement(_localMachineName);
                SettingsRootNode.AppendChild(machineNode);
            }

            if (machineNode == null)
            {
                machineNode = SettingsXml.CreateElement(_localMachineName);
                SettingsRootNode.AppendChild(machineNode);
            }

            var settingNode = SettingsXml.CreateElement(propVal.Name);

            settingNode.InnerText = propVal.SerializedValue.ToString();
            machineNode.AppendChild(settingNode);
        }
コード例 #2
0
        /// <summary>
        /// Store the value as an element of the Settings Root Node
        /// </summary>
        private void CreateRoamingValue(SettingsPropertyValue propVal)
        {
            var serializedValue = propVal.SerializedValue;

            if (serializedValue != null)
            {
                if (SettingsRootNode == null)
                {
                    throw new ArgumentNullException(nameof(SettingsRootNode));
                }
                if (SettingsXml == null)
                {
                    throw new ArgumentNullException(nameof(SettingsXml));
                }
                var settingNode = SettingsXml.CreateElement(propVal.Name);
                settingNode.InnerText = serializedValue.ToString();
                SettingsRootNode.AppendChild(settingNode);
            }
        }