Exemplo n.º 1
0
        internal void Merge(UnknownItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            foreach (var attribute in item.Attributes)
            {
                AddOrUpdateAttribute(attribute.Key, attribute.Value);
            }

            foreach (var child in item.Children)
            {
                if (_mutableChildren.TryGetValue(child, out var existingChild))
                {
                    if (existingChild is SettingItem childItem)
                    {
                        childItem.Update(child as SettingItem);
                    }
                }
                else
                {
                    _mutableChildren.Add(child, child);
                }
            }
        }
Exemplo n.º 2
0
        public void UpdateSubsections(string section, string subsection, IReadOnlyList <SettingValue> values)
        {
            if (string.IsNullOrEmpty(section))
            {
                throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(section));
            }

            if (string.IsNullOrEmpty(subsection))
            {
                throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(subsection));
            }

            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            if (values.Any())
            {
                SettingItem itemToAdd = null;

                if (string.Equals(ConfigurationConstants.CredentialsSectionName, section, StringComparison.OrdinalIgnoreCase) &&
                    GetCredentialsItemValues(values, out var username, out var password, out var isPasswordClearText, out var validAuthenticationTypes))
                {
                    itemToAdd = new CredentialsItem(subsection, username, password, isPasswordClearText, validAuthenticationTypes);
                }
                else
                {
                    itemToAdd = new UnknownItem(subsection, attributes: null, children: values.Select(v => TransformSettingValue(subsection, v)));
                }

                AddOrUpdate(section, itemToAdd);
            }
Exemplo n.º 3
0
        internal override SettingBase Clone()
        {
            var newSetting = new UnknownItem(ElementName, Attributes, Children.Select(c => c.Clone()));

            if (Origin != null)
            {
                newSetting.SetOrigin(Origin);
            }

            return(newSetting);
        }