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); }
private DomAttribute SetValue(DomAttribute result, string value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } result.Value = value; return(result); }
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); }
public override bool Remove(DomAttribute item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } item.Unlink(); return(_items.Remove(item) && NotifyAttributeChanged(item, item.Value)); }
public override void Add(DomAttribute item) { if (item == null) { throw new ArgumentNullException(nameof(item)); } item.Link(this); _items.Add(item); }
protected virtual void WriteAttribute(DomAttribute attribute) { if (attribute == null) { throw new ArgumentNullException(nameof(attribute)); } WriteStartAttribute(attribute.Name); WriteValue(attribute.Value); WriteEndAttribute(); }
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); } }
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); }
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); }
public override void WriteEndDocument() { _state.EndDocument(); _current = null; _attribute = null; }
public override void WriteEndAttribute() { _state.EndAttribute(); _attribute = null; }
public override void WriteStartAttribute(DomName name) { _state.StartAttribute(); _attribute = _current.AppendAttribute(name); }
public override void WriteStartElement(DomName name) { _state.StartElement(); _current = _current.AppendElement(name); _attribute = null; }
void IDomNodeVisitor.Visit(DomAttribute attribute) { VisitAttribute(attribute); }
public override void Insert(int index, DomAttribute item) { _items.Insert(index, item); }
public override int IndexOf(DomAttribute item) { return(FastContains(item) ? _items.IndexOf(item) : -1); }
public virtual void SetAttribute(DomAttribute attribute) { }
public override void SetAttribute(DomAttribute attribute) { _attribute = attribute; }
private bool FastContains(DomAttribute item) { return(item.SiblingAttributes == this); }
private bool NotifyAttributeChanged(DomAttribute item, string oldValue) { item.OwnerDocument.AttributeValueChanged(item, OwnerElement, oldValue); return(true); }