C# Class Svg.SvgElementIdManager

Provides methods to ensure element ID's are valid and unique.
ファイルを表示 Open project: prepare/HTML-Renderer Class Usage Examples

Public Methods

Method Description
Add ( SvgElement element ) : void

Adds the specified SvgElement for ID management.

AddAndForceUniqueID ( SvgElement element, SvgElement sibling, bool autoForceUniqueID = true, Action logElementOldIDNewID = null ) : bool

Adds the specified SvgElement for ID management. And can auto fix the ID if it already exists or it starts with a number.

EnsureValidId ( string id, bool autoForceUniqueID = false ) : string

Ensures that the specified ID is valid within the containing SvgDocument.

GetElementById ( Uri uri ) : SvgElement
GetElementById ( string id ) : SvgElement

Retrieves the SvgElement with the specified ID.

Remove ( SvgElement element ) : void

Removed the specified SvgElement from ID management.

SvgElementIdManager ( SvgDocument document ) : System

Initialises a new instance of an SvgElementIdManager.

Protected Methods

Method Description
OnAdded ( SvgElement element ) : void
OnRemoved ( SvgElement element ) : void

Method Details

Add() public method

Adds the specified SvgElement for ID management.
public Add ( SvgElement element ) : void
element SvgElement The to be managed.
return void

AddAndForceUniqueID() public method

Adds the specified SvgElement for ID management. And can auto fix the ID if it already exists or it starts with a number.
public AddAndForceUniqueID ( SvgElement element, SvgElement sibling, bool autoForceUniqueID = true, Action logElementOldIDNewID = null ) : bool
element SvgElement The to be managed.
sibling SvgElement
autoForceUniqueID bool Pass true here, if you want the ID to be fixed
logElementOldIDNewID Action If not null, the action is called before the id is fixed
return bool

EnsureValidId() public method

Ensures that the specified ID is valid within the containing SvgDocument.
/// The ID cannot start with a digit. /// An element with the same ID already exists within the containing . ///
public EnsureValidId ( string id, bool autoForceUniqueID = false ) : string
id string A containing the ID to validate.
autoForceUniqueID bool Creates a new unique id .
return string

GetElementById() public method

public GetElementById ( Uri uri ) : SvgElement
uri System.Uri
return SvgElement

GetElementById() public method

Retrieves the SvgElement with the specified ID.
public GetElementById ( string id ) : SvgElement
id string A containing the ID of the element to find.
return SvgElement

OnAdded() protected method

protected OnAdded ( SvgElement element ) : void
element SvgElement
return void

OnRemoved() protected method

protected OnRemoved ( SvgElement element ) : void
element SvgElement
return void

Remove() public method

Removed the specified SvgElement from ID management.
public Remove ( SvgElement element ) : void
element SvgElement The to be removed from ID management.
return void

SvgElementIdManager() public method

Initialises a new instance of an SvgElementIdManager.
public SvgElementIdManager ( SvgDocument document ) : System
document SvgDocument The containing the s to manage.
return System