コード例 #1
0
 /// <summary>
 /// Copies the attributes from the source element to the target
 /// element. Each attribute will be recreated on the target.
 /// </summary>
 /// <param name="source">The source of the attributes.</param>
 /// <param name="target">
 /// The target where to create the attributes.
 /// </param>
 protected static void CopyAttributes(Element source, Element target)
 {
     foreach (var attribute in source._attributes)
     {
         var attr = new Attr(attribute.Prefix, attribute.LocalName, attribute.Value, attribute.NamespaceUri);
         target._attributes.FastAddItem(attr);
     }
 }
コード例 #2
0
        internal void RaiseChangedEvent(Attr attr, String newValue, String oldValue)
        {
            var element = default(Element);

            if (_owner.TryGetTarget(out element))
            {
                element.AttributeChanged(attr.LocalName, attr.NamespaceUri, oldValue, newValue);
            }
        }
コード例 #3
0
        /// <summary>
        /// Adds all given attributes to the element, without any duplicate checks.
        /// </summary>
        /// <param name="element">The node with the target attributes.</param>
        /// <param name="attributes">The attributes to set.</param>
        public static void SetAttributes(this Element element, List<KeyValuePair<String, String>> attributes)
        {
            var container = element.Attributes;

            for (var i = 0; i < attributes.Count; i++)
            {
                var attribute = attributes[i];
                var item = new Attr(attribute.Key, attribute.Value);
                container.FastAddItem(item);
            }
        }
コード例 #4
0
ファイル: Element.cs プロジェクト: zidanfei/AngleSharp
        protected void CloneElement(Element element, Boolean deep)
        {
            CloneNode(element, deep);

            foreach (var attribute in _attributes)
            {
                var attr = new Attr(attribute.Prefix, attribute.LocalName, attribute.Value, attribute.NamespaceUri);
                element._attributes.FastAddItem(attr);
            }

            element.SetupElement();
        }
コード例 #5
0
 internal void FastAddItem(Attr attr)
 {
     _items.Add(attr);
 }
コード例 #6
0
ファイル: Element.cs プロジェクト: howej/AngleSharp
 /// <summary>
 /// Copies the attributes from the source element to the target
 /// element. Each attribute will be recreated on the target.
 /// </summary>
 /// <param name="source">The source of the attributes.</param>
 /// <param name="target">
 /// The target where to create the attributes.
 /// </param>
 protected static void CopyAttributes(Element source, Element target)
 {
     foreach (var attribute in source._attributes)
     {
         var attr = new Attr(attribute.Prefix, attribute.LocalName, attribute.Value, attribute.NamespaceUri);
         target._attributes.FastAddItem(attr);
     }
 }
コード例 #7
0
ファイル: Element.cs プロジェクト: zanyants/AngleSharp
 /// <summary>
 /// Adds an attribute.
 /// </summary>
 /// <param name="attr">The attribute to add.</param>
 public void AddAttribute(Attr attr)
 {
     _attributes.FastAddItem(attr);
 }