public override int IndexOf(DomAttribute item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     return(Items.IndexOf(item));
 }
 public DomObjectQuery Before(params DomAttribute[] previousAttributes)
 {
     if (previousAttributes == null)
     {
         throw new ArgumentNullException(nameof(previousAttributes));
     }
     return(Each(n => n.Before(previousAttributes), n => n.Before(DomAttribute.CloneAll(previousAttributes))));
 }
        private void SetItem(int index, DomAttribute item)
        {
            var old = Items[index];

            _map.Remove(Items[index].Name);
            _map.Add(item.Name, item);
            _items[index] = item;
        }
 public DomObjectQuery InsertAfter(DomAttribute other)
 {
     if (other == null)
     {
         throw new ArgumentNullException(nameof(other));
     }
     return(Each(n => n.InsertBefore(other)));
 }
 public DomObjectQuery After(params DomAttribute[] nextAttributes)
 {
     if (nextAttributes == null)
     {
         throw new ArgumentNullException(nameof(nextAttributes));
     }
     return(Each(n => n.After(nextAttributes), n => n.After(DomAttribute.CloneAll(nextAttributes))));
 }
 public DomObjectQuery After(DomAttribute nextAttribute)
 {
     if (nextAttribute == null)
     {
         throw new ArgumentNullException(nameof(nextAttribute));
     }
     return(After(new [] { nextAttribute }));
 }
 public DomObjectQuery Before(DomAttribute previousAttribute)
 {
     if (previousAttribute == null)
     {
         throw new ArgumentNullException(nameof(previousAttribute));
     }
     return(Each(n => n.Before(previousAttribute)));
 }
        public override void Insert(int index, DomAttribute item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            InsertItem(index, item);
        }
Exemplo n.º 9
0
 private DomAttribute SetValue(DomAttribute result, string value)
 {
     if (value == null)
     {
         throw new ArgumentNullException(nameof(value));
     }
     result.Value = value;
     return(result);
 }
Exemplo n.º 10
0
        protected virtual void VisitAttribute(DomAttribute attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            DefaultVisit(attribute);
        }
        public override void Add(DomAttribute item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            InsertItem(Count, item);
        }
Exemplo n.º 12
0
        public override bool Remove(DomAttribute item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            item.Unlink();

            return(_items.Remove(item) && NotifyAttributeChanged(item, item.Value));
        }
Exemplo n.º 13
0
        public override void Add(DomAttribute item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            item.Link(this);
            _items.Add(item);
        }
Exemplo n.º 14
0
        protected virtual void WriteAttribute(DomAttribute attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            WriteStartAttribute(attribute.Name);
            WriteValue(attribute.Value);
            WriteEndAttribute();
        }
Exemplo n.º 15
0
        internal void AttributeValueChanged(DomAttribute attr, DomElement element, string oldValue)
        {
            DomAttributeEvent evt = null;

            foreach (var o in GetObservers(DomObserverEventScope.SpecificAttribute(attr.Name), element))
            {
                if (evt == null)
                {
                    evt = new DomAttributeEvent(element, attr.Name, oldValue);
                }
                o.OnNext(evt);
            }
        }
Exemplo n.º 16
0
        private DomAttribute ApplySchema(DomAttribute attr)
        {
            if (Schema == null)
            {
                return(attr);
            }
            var def = Schema.AttributeDefinitions[attr.Name];

            if (def != null && def.ValueType != null)
            {
                attr.DomValue = DomValue.Create(def.ValueType);
            }
            return(attr);
        }
        public override bool Remove(DomAttribute item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            int  index  = IndexOf(item);
            bool bounds = index >= 0;

            if (bounds)
            {
                RemoveItem(index);
            }

            return(bounds);
        }
Exemplo n.º 18
0
        private bool TryExtractXmlnsPrefixMapping(DomAttribute a, out string prefix)
        {
            // xmlns attributes are never mapped to QNames, so we can assert directly
            // on the format of the attribute

            // TODO This could be re-entrant due to a.LocalName referencing
            // DomName => XmlNameContext => this resolver

            var xml = XmlNameSemantics.FromName(a.LocalName);

            if (xml.Prefix == "xmlns")
            {
                prefix = xml.LocalName;
                return(true);
            }
            prefix = null;
            return(false);
        }
        // TODO Comparer should be by name

        private void InsertItem(int index, DomAttribute item)
        {
            int existing = IndexOf(item.Name);

            if (existing < 0)
            {
            }
            else if (Items[existing] == item)
            {
                return;
            }
            else
            {
                throw DomFailure.AttributeWithGivenNameExists(item.Name, nameof(item));
            }

            _map.Add(item.Name, item);
            Items.Insert(index, item);
        }
Exemplo n.º 20
0
 public override void WriteEndDocument()
 {
     _state.EndDocument();
     _current   = null;
     _attribute = null;
 }
Exemplo n.º 21
0
 public override void WriteEndAttribute()
 {
     _state.EndAttribute();
     _attribute = null;
 }
Exemplo n.º 22
0
 public override void WriteStartAttribute(DomName name)
 {
     _state.StartAttribute();
     _attribute = _current.AppendAttribute(name);
 }
Exemplo n.º 23
0
 public override void WriteStartElement(DomName name)
 {
     _state.StartElement();
     _current   = _current.AppendElement(name);
     _attribute = null;
 }
Exemplo n.º 24
0
 void IDomNodeVisitor.Visit(DomAttribute attribute)
 {
     VisitAttribute(attribute);
 }
Exemplo n.º 25
0
 public override void Insert(int index, DomAttribute item)
 {
     _items.Insert(index, item);
 }
Exemplo n.º 26
0
 public override int IndexOf(DomAttribute item)
 {
     return(FastContains(item)
         ? _items.IndexOf(item)
         : -1);
 }
Exemplo n.º 27
0
 public virtual void SetAttribute(DomAttribute attribute)
 {
 }
Exemplo n.º 28
0
 public override void SetAttribute(DomAttribute attribute)
 {
     _attribute = attribute;
 }
Exemplo n.º 29
0
 private bool FastContains(DomAttribute item)
 {
     return(item.SiblingAttributes == this);
 }
Exemplo n.º 30
0
 private bool NotifyAttributeChanged(DomAttribute item, string oldValue)
 {
     item.OwnerDocument.AttributeValueChanged(item, OwnerElement, oldValue);
     return(true);
 }