C# Class CsQuery.Implementation.DomObject

Something that appears in the DOM. This is essentially the same as a Node in the browser DOM, but IDomObject represents only things that may appear in the DOM (e.g. not an attribute, document, doctype)
Inheritance: IDomObject, IDomNode
显示文件 Open project: prepare/HTML-Renderer Class Usage Examples

Protected Properties

Property Type Description
DocInfo DocumentInfo

Private Properties

Property Type Description
ICloneable object
IDomNode IDomNode
Render void
Render void
SetDocFlags void

Public Methods

Method Description
AddClass ( string className ) : bool

Adds the class.

AddStyle ( string styleString ) : void

Adds a style descriptor to this element, validating the style name and value against the CSS3 ruleset. The string should be of the form "styleName: styleDef;", e.g. "width: 10px;" The trailing semicolon is optional.

AddStyle ( string styleString, bool strict ) : void

Adds a style descriptor to this element, optionally validating against the CSS3 ruleset. The default method always validates; this overload should be used if validation is not desired.

AppendChild ( IDomObject element ) : void

Adds a node to the end of the list of children of a specified parent node. If the node already exists it is removed from current parent node, then added to new parent node.

AppendChildUnsafe ( IDomObject element ) : void

Appends a child without checking to see if its already a member of the DOM. For use in DOM construction to avoid unneeded overhead.

Clone ( ) : IDomObject

Clone this element.

CloneChildren ( ) : IEnumerable

An enumeration of clones of the chilren of this object

CompareTo ( IDomObject other ) : int

Compares this IDomObject object to another to determine their relative ordering.

DescendantCount ( ) : int

Return the total number of descendants of this element.

ElementHtml ( ) : string

Returns the HTML for this element, but ignoring children/innerHTML.

GetAncestors ( ) : IEnumerable

Returns all of the ancestors of the given node, in descending order of their depth from the root node.

GetAttribute ( string name ) : string

Returns the value of the named attribute on the specified element. If the named attribute does not exist, the value returned will either be null or "" (the empty string)

GetAttribute ( string name, string defaultValue ) : string

Returns the value of the named attribute on the specified element. If the named attribute does not exist, the value returned will either be the provide "defaultValue".

GetDescendentElements ( ) : IEnumerable

Returns all IDomElement descendents of the given node, in pre-order depth first order.

GetDescendents ( ) : IEnumerable

Returns all of the descendents of the given node, in pre-order depth first order.

HasAttribute ( string name ) : bool

Returns a boolean value indicating whether the specified element has the specified attribute or not.

HasClass ( string className ) : bool

Returns a boolean value indicating whether the named class exists on this element.

HasStyle ( string styleName ) : bool

Returns a boolean value indicating whether the named style is defined in the styles for this element.

IndexKeys ( ) : IEnumerable

Enumerates index keys in this collection.

IndexKeysRanged ( ) : IEnumerable

Enumerates index keys for this element.

InsertAfter ( IDomObject newNode, IDomObject referenceNode ) : void

Inserts the specified node after a reference element as a child of the current node.

InsertBefore ( IDomObject newNode, IDomObject referenceNode ) : void

Inserts the specified node before a reference element as a child of the current node.

Remove ( ) : void

Removes this object from it's parent, and consequently the Document, if any, to which it belongs.

RemoveAttribute ( string name ) : bool

Removes an attribute from the specified element.

RemoveChild ( IDomObject element ) : void

Removes a child node from the DOM. Returns removed node.

RemoveClass ( string className ) : bool

Removes the named class from the classes defined for this element.

RemoveStyle ( string name ) : bool

Removes the named style from this element.

Render ( ) : string

Renders the complete HTML for this element, including its children.

Render ( DomRenderingOptions options ) : string

Renders the complete HTML for this element, including its children.

Render ( IOutputFormatter formatter ) : string

Renders the complete HTML for this element, including its children, using the specified OutputFormatter.

Render ( IOutputFormatter formatter, TextWriter writer ) : void

Renders the complete HTML for this element, including its children, using the specified OutputFormatter.

SetAttribute ( string name ) : void

Adds a new boolean attribute or sets its value to true.

SetAttribute ( string name, string value ) : void

Adds a new attribute or changes the value of an existing attribute on the specified element.

ToString ( ) : string

The ToString() override for an object depends on the type of element.

TryGetAttribute ( string name, string &value ) : bool

Try to get a named attribute.

this ( int index ) : IDomObject

The child node at the specified index.

this ( string attribute ) : string

The child node at the specified index.

Protected Methods

Method Description
CloneImplementation ( ) : IDomObject

The implementation for Clone.

GetDepth ( ) : int

Gets the depth of the current node.

GetPath ( ) : ushort[]

Gets the full path to this document.

GetPath_UnOptimized ( ) : ushort[]

Gets the full path to this document.

UpdateDocumentFlags ( ) : void

Updates the cached Document and property flags.

UpdateDocumentFlags ( IDomDocument document ) : void

Updates the cached Document and property flags.

Private Methods

Method Description
ICloneable ( ) : object

Makes a deep copy of this object.

IDomNode ( ) : IDomNode

Makes a deep copy of this object.

Render ( StringBuilder sb ) : void
Render ( StringBuilder sb, DomRenderingOptions options ) : void
SetDocFlags ( ) : void

Method Details

AddClass() public method

Adds the class.
/// Thrown when the requested operation is invalid. ///
public AddClass ( string className ) : bool
className string /// The class name for which to test. ///
return bool

AddStyle() public method

Adds a style descriptor to this element, validating the style name and value against the CSS3 ruleset. The string should be of the form "styleName: styleDef;", e.g. "width: 10px;" The trailing semicolon is optional.
/// Thrown when the requested operation is invalid. ///
public AddStyle ( string styleString ) : void
styleString string /// The style string. ///
return void

AddStyle() public method

Adds a style descriptor to this element, optionally validating against the CSS3 ruleset. The default method always validates; this overload should be used if validation is not desired.
/// Thrown when the requested operation is invalid. ///
public AddStyle ( string styleString, bool strict ) : void
styleString string /// An object encapsulating the Styles associated with this element. ///
strict bool /// true to enforce validation of CSS3 styles. ///
return void

AppendChild() public method

Adds a node to the end of the list of children of a specified parent node. If the node already exists it is removed from current parent node, then added to new parent node.
/// Thrown when the requested operation is invalid. ///
public AppendChild ( IDomObject element ) : void
element IDomObject /// The element to append. ///
return void

AppendChildUnsafe() public method

Appends a child without checking to see if its already a member of the DOM. For use in DOM construction to avoid unneeded overhead.
/// Thrown when the requested operation is invalid. ///
public AppendChildUnsafe ( IDomObject element ) : void
element IDomObject /// The element to append. ///
return void

Clone() public method

Clone this element.
public Clone ( ) : IDomObject
return IDomObject

CloneChildren() public method

An enumeration of clones of the chilren of this object
public CloneChildren ( ) : IEnumerable
return IEnumerable

CloneImplementation() protected abstract method

The implementation for Clone.
protected abstract CloneImplementation ( ) : IDomObject
return IDomObject

CompareTo() public method

Compares this IDomObject object to another to determine their relative ordering.
public CompareTo ( IDomObject other ) : int
other IDomObject /// Another instance to compare. ///
return int

DescendantCount() public method

Return the total number of descendants of this element.
public DescendantCount ( ) : int
return int

ElementHtml() public method

Returns the HTML for this element, but ignoring children/innerHTML.
public ElementHtml ( ) : string
return string

GetAncestors() public method

Returns all of the ancestors of the given node, in descending order of their depth from the root node.
public GetAncestors ( ) : IEnumerable
return IEnumerable

GetAttribute() public method

Returns the value of the named attribute on the specified element. If the named attribute does not exist, the value returned will either be null or "" (the empty string)
public GetAttribute ( string name ) : string
name string /// The attribute name. ///
return string

GetAttribute() public method

Returns the value of the named attribute on the specified element. If the named attribute does not exist, the value returned will either be the provide "defaultValue".
public GetAttribute ( string name, string defaultValue ) : string
name string /// The attribute name. ///
defaultValue string /// A string to return if the attribute does not exist. ///
return string

GetDepth() protected method

Gets the depth of the current node.
protected GetDepth ( ) : int
return int

GetDescendentElements() public method

Returns all IDomElement descendents of the given node, in pre-order depth first order.
public GetDescendentElements ( ) : IEnumerable
return IEnumerable

GetDescendents() public method

Returns all of the descendents of the given node, in pre-order depth first order.
public GetDescendents ( ) : IEnumerable
return IEnumerable

GetPath() protected method

Gets the full path to this document.
protected GetPath ( ) : ushort[]
return ushort[]

GetPath_UnOptimized() protected method

Gets the full path to this document.
protected GetPath_UnOptimized ( ) : ushort[]
return ushort[]

HasAttribute() public method

Returns a boolean value indicating whether the specified element has the specified attribute or not.
public HasAttribute ( string name ) : bool
name string /// The attribute name. ///
return bool

HasClass() public method

Returns a boolean value indicating whether the named class exists on this element.
public HasClass ( string className ) : bool
className string /// The class name for which to test. ///
return bool

HasStyle() public method

Returns a boolean value indicating whether the named style is defined in the styles for this element.
public HasStyle ( string styleName ) : bool
styleName string /// Name of the style to test. ///
return bool

IndexKeys() public method

Enumerates index keys in this collection.
/// Thrown when the requested operation is invalid. ///
public IndexKeys ( ) : IEnumerable
return IEnumerable

IndexKeysRanged() public method

Enumerates index keys for this element.
/// Thrown when the requested operation is not valid for this element type ///
public IndexKeysRanged ( ) : IEnumerable
return IEnumerable

InsertAfter() public method

Inserts the specified node after a reference element as a child of the current node.
/// Thrown when the requested operation is invalid. ///
public InsertAfter ( IDomObject newNode, IDomObject referenceNode ) : void
newNode IDomObject /// The new node to be inserted. ///
referenceNode IDomObject /// The node after which the new node will be inserted. ///
return void

InsertBefore() public method

Inserts the specified node before a reference element as a child of the current node.
/// Thrown when the requested operation is invalid. ///
public InsertBefore ( IDomObject newNode, IDomObject referenceNode ) : void
newNode IDomObject /// The node to insert. ///
referenceNode IDomObject /// The node before which the new node will be inserted. ///
return void

Remove() public method

Removes this object from it's parent, and consequently the Document, if any, to which it belongs.
/// Thrown when the the node has no parent. ///
public Remove ( ) : void
return void

RemoveAttribute() public method

Removes an attribute from the specified element.
/// Thrown when the requested operation is invalid. ///
public RemoveAttribute ( string name ) : bool
name string /// The attribute name. ///
return bool

RemoveChild() public method

Removes a child node from the DOM. Returns removed node.
/// Thrown when the requested operation is invalid. ///
public RemoveChild ( IDomObject element ) : void
element IDomObject /// The element to remove. ///
return void

RemoveClass() public method

Removes the named class from the classes defined for this element.
/// Thrown when the requested operation is invalid. ///
public RemoveClass ( string className ) : bool
className string /// The class name to remove. ///
return bool

RemoveStyle() public method

Removes the named style from this element.
/// Thrown when the requested operation is invalid. ///
public RemoveStyle ( string name ) : bool
name string /// The style name. ///
return bool

Render() public method

Renders the complete HTML for this element, including its children.
public Render ( ) : string
return string

Render() public method

Renders the complete HTML for this element, including its children.
public Render ( DomRenderingOptions options ) : string
options DomRenderingOptions
return string

Render() public method

Renders the complete HTML for this element, including its children, using the specified OutputFormatter.
public Render ( IOutputFormatter formatter ) : string
formatter IOutputFormatter /// The formatter. ///
return string

Render() public method

Renders the complete HTML for this element, including its children, using the specified OutputFormatter.
public Render ( IOutputFormatter formatter, TextWriter writer ) : void
formatter IOutputFormatter /// The formatter that controls how the ouput is rendered. ///
writer System.IO.TextWriter /// The writer to which output should be written. ///
return void

SetAttribute() public method

Adds a new boolean attribute or sets its value to true.
/// Thrown when the object type does not support attributes ///
public SetAttribute ( string name ) : void
name string /// The attribute name. ///
return void

SetAttribute() public method

Adds a new attribute or changes the value of an existing attribute on the specified element.
/// Thrown when the object type does not support attributes ///
public SetAttribute ( string name, string value ) : void
name string /// The attribute name. ///
value string /// For input elements, the "value" property of this element. Returns null for other element /// types. ///
return void

ToString() public method

The ToString() override for an object depends on the type of element.
public ToString ( ) : string
return string

TryGetAttribute() public method

Try to get a named attribute.
public TryGetAttribute ( string name, string &value ) : bool
name string /// The attribute name. ///
value string /// The attribute value, or null if the named attribute does not exist. ///
return bool

UpdateDocumentFlags() protected method

Updates the cached Document and property flags.
protected UpdateDocumentFlags ( ) : void
return void

UpdateDocumentFlags() protected method

Updates the cached Document and property flags.
protected UpdateDocumentFlags ( IDomDocument document ) : void
document IDomDocument /// A reference to the owning document. This is also the topmost node in the tree. ///
return void

this() public method

The child node at the specified index.
public this ( int index ) : IDomObject
index int /// The zero-based index of the child node to access. ///
return IDomObject

this() public method

The child node at the specified index.
public this ( string attribute ) : string
attribute string /// The zero-based index of the child node to access. ///
return string

Property Details

DocInfo protected_oe property

Information describing metadata about the element's owning document. This is essentially a cache, it prevents us from having to check to see if there's an owning document and access it directly. This is an optimizaton as this happens often.
protected DocumentInfo DocInfo
return DocumentInfo