Table of Contents

Class SvgContentList

Namespace
Egami.Svg
Assembly
Egami.Svg.dll

An element's content in file order: child elements, text, comments and processing instructions. Changes mark the document's render tree for rebuilding.

public sealed class SvgContentList : Collection<SvgContent>, IList<SvgContent>, ICollection<SvgContent>, IReadOnlyList<SvgContent>, IReadOnlyCollection<SvgContent>, IEnumerable<SvgContent>, IList, ICollection, IEnumerable
Inheritance
SvgContentList
Implements
Inherited Members

Examples

SvgDocument document = SvgDocument.Parse(Icon);

// Elements, attributes and text are an editable tree, like XDocument's.
SvgElement body = document.FindById("body")!;
body.Attributes["fill"] = "#c33";
body.Attributes.Set("href", "#other", SvgNamespaces.XLink, "xlink");

SvgElement dot = new("circle");
dot.Attributes["cx"] = "12";
dot.Attributes["cy"] = "12";
dot.Attributes["r"] = "3";
document.Root.Children.Add(dot);
document.Root.Children.Add(new SvgComment(" added in code "));

foreach (SvgElement element in document.Root.Elements())
{
    Console.WriteLine($"{element.Name}: {element.Attributes.Count} attributes");
}

Methods

ClearItems()

Removes all elements from the Collection<T>.

protected override void ClearItems()

InsertItem(int, SvgContent)

Inserts an element into the Collection<T> at the specified index.

protected override void InsertItem(int index, SvgContent item)

Parameters

index int

The zero-based index at which item should be inserted.

item SvgContent

The object to insert. The value can be null for reference types.

Exceptions

ArgumentOutOfRangeException

index is less than zero.

-or-

index is greater than Count.

RemoveItem(int)

Removes the element at the specified index of the Collection<T>.

protected override void RemoveItem(int index)

Parameters

index int

The zero-based index of the element to remove.

Exceptions

ArgumentOutOfRangeException

index is less than zero.

-or-

index is equal to or greater than Count.

SetItem(int, SvgContent)

Replaces the element at the specified index.

protected override void SetItem(int index, SvgContent item)

Parameters

index int

The zero-based index of the element to replace.

item SvgContent

The new value for the element at the specified index. The value can be null for reference types.

Exceptions

ArgumentOutOfRangeException

index is less than zero.

-or-

index is greater than Count.