예제 #1
0
        internal override void Update(SettingItem other)
        {
            var owners = other as OwnersItem;

            if (!owners.Content.Any())
            {
                throw new InvalidOperationException(Resources.OwnersItemMustHaveAtLeastOneOwner);
            }

            base.Update(other);

            if (!Equals(owners))
            {
                XElementUtility.RemoveIndented(_content.Node);
                Content = owners.Content;

                _content = new SettingText(string.Join(OwnersListSeparator.ToString(), Content));

                if (Origin != null)
                {
                    _content.SetOrigin(Origin);

                    if (Node != null)
                    {
                        _content.SetNode(_content.AsXNode());
                        (Node as XElement).Add(_content.Node);
                        Origin.IsDirty = true;
                    }
                }
            }
        }
예제 #2
0
        internal override XNode AsXNode()
        {
            if (Node is XElement)
            {
                return(Node);
            }

            _content.Value = string.Join(OwnersListSeparator.ToString(), Content);

            var element = new XElement(ElementName, _content.AsXNode());

            foreach (var attr in Attributes)
            {
                element.SetAttributeValue(attr.Key, attr.Value);
            }

            return(element);
        }