Difference between revisions of "DOMObject"

From Virtual World Web Wiki
Jump to: navigation, search
(Documentation for the DOMObject class)
(Documentation for the DOMObject class)
Line 245: Line 245:
  
 
:{{CSharp|bool Contains(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|bool Contains(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Searches the specified object within the specified scope and matching the specified predicate
  
 
:{{CSharp|bool Contains<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|bool Contains<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Searches the specified object within the specified scope and matching the specified predicate and type
  
 
:{{CSharp|T2 ContainsTest<T1, T2>(T1 value, T2 value2)}}
 
:{{CSharp|T2 ContainsTest<T1, T2>(T1 value, T2 value2)}}
Line 253: Line 257:
  
 
:{{CSharp|int Count<T>()}}
 
:{{CSharp|int Count<T>()}}
 +
::
 +
::Returns a count of all child nodes that match the specified type
  
 
:{{CSharp|int Count<T>(DOMSearchLevel applyTo)}}
 
:{{CSharp|int Count<T>(DOMSearchLevel applyTo)}}
Line 259: Line 265:
  
 
:{{CSharp|int Count<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|int Count<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Returns a count of all nodes within the specified scope and matching the supplied predicate and type
  
 
:{{CSharp|int Count(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|int Count(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Returns a count of all nodes within the specified scope and matching the supplied predicate
  
 
:{{CSharp|DOMObject Detach()}}
 
:{{CSharp|DOMObject Detach()}}
Line 291: Line 301:
  
 
:{{CSharp|DOMObject First(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|DOMObject First(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Finds the first DOMObject in the specified scope and matching the supplied predicate
  
 
:{{CSharp|T First<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|T First<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Finds the first DOMObject in the specified scope and matching the supplied predicate and type
  
 
:{{CSharp|DOMObject FirstOrDefault(DOMSearchLevel applyTo)}}
 
:{{CSharp|DOMObject FirstOrDefault(DOMSearchLevel applyTo)}}
Line 303: Line 317:
  
 
:{{CSharp|DOMObject FirstOrDefault(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|DOMObject FirstOrDefault(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Finds the first DOMObject in the specified scope and matching the supplied predicate
  
 
:{{CSharp|T FirstOrDefault<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|T FirstOrDefault<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Finds the first DOMObject in the specified scope and matching the supplied predicate and type
  
 
:{{CSharp|void ForEach(Func<DOMObject, bool> predicate, Action<DOMObject> action, DOMSearchLevel applyTo)}}
 
:{{CSharp|void ForEach(Func<DOMObject, bool> predicate, Action<DOMObject> action, DOMSearchLevel applyTo)}}
 +
::
 +
::Executes the specified action on all nodes withing the specified scope and matching the supplied predicate
  
 
:{{CSharp|void ForEach<T>(Func<T, bool> predicate, Action<T> action, DOMSearchLevel applyTo)}}
 
:{{CSharp|void ForEach<T>(Func<T, bool> predicate, Action<T> action, DOMSearchLevel applyTo)}}
 +
::
 +
::Executes the specified action on all nodes withing the specified scope and matching the supplied predicate and type
  
 
:{{CSharp|TResult GetAttributeValue<TResult>(string attributeName, string propertyName)}}
 
:{{CSharp|TResult GetAttributeValue<TResult>(string attributeName, string propertyName)}}
Line 319: Line 341:
  
 
:{{CSharp|T GetLocalProperty<T>(string key, Func<T> defaultSelector)}}
 
:{{CSharp|T GetLocalProperty<T>(string key, Func<T> defaultSelector)}}
 +
::
 +
::Gets the value of a local property of this DOM node
  
 
:{{CSharp|IEnumerable<string> GetPropertiesWithAttribute(string attributeName)}}
 
:{{CSharp|IEnumerable<string> GetPropertiesWithAttribute(string attributeName)}}
Line 345: Line 369:
  
 
:{{CSharp|T ParentOfType<T>()}}
 
:{{CSharp|T ParentOfType<T>()}}
 +
::
 +
::Searches up the DOM hierarchy looking for a parent of the specified type
  
 
:{{CSharp|DOMObject QuerySelector(string selector)}}
 
:{{CSharp|DOMObject QuerySelector(string selector)}}
Line 363: Line 389:
  
 
:{{CSharp|int RemoveLocalProperties(Func<string, bool> predicate)}}
 
:{{CSharp|int RemoveLocalProperties(Func<string, bool> predicate)}}
 +
::
 +
::Removes any local properties, using a predicate function to test the keys
  
 
:{{CSharp|object RemoveLocalProperty(string key)}}
 
:{{CSharp|object RemoveLocalProperty(string key)}}
Line 373: Line 401:
  
 
:{{CSharp|void Revalidate(Func<DOMObject, bool> validationCallback)}}
 
:{{CSharp|void Revalidate(Func<DOMObject, bool> validationCallback)}}
 +
::
 +
::Used internally by the instance host to validate DOM nodes
  
 
:{{CSharp|void SetLocalProperty(string key, object value)}}
 
:{{CSharp|void SetLocalProperty(string key, object value)}}
Line 389: Line 419:
  
 
:{{CSharp|IEnumerable<DOMObject> Where(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|IEnumerable<DOMObject> Where(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Returns all nodes withing the specified scope and matching the specified predicate
  
 
:{{CSharp|IEnumerable<T> Where<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 
:{{CSharp|IEnumerable<T> Where<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)}}
 +
::
 +
::Returns all nodes withing the specified scope and matching the specified predicate and type
  
 
__NOTOC____NOEDITSECTION__
 
__NOTOC____NOEDITSECTION__

Revision as of 21:39, 12 October 2016

This is the base class for all DOM node types. A DOM Object is essentially a collection of properties (name value pairs) and a collection of child DOM Objects forming a hierarchy. Changes to properties and changes to the hierarchy cause Update events to bubble up firing at each node until the the topmost node is reached.

See also: Server Scripting

Remarks [edit]

Properties

bool Accessable {get;}
True if the object is both Enabled and Validated and if it has a parent, that parent is accessible as well
DOMAttributeCache AttributeCache {get; set;}
Used by the server to optimize Object Type attribute requests
DOMAttributeSet Attributes {get;}
A collection of DOMAttributes defined on this object via the Object Type system
Guid? BaseTypeID {get; set;}
The type ID of the root Object Type in a derived Object Type Reference chain
DOMObjectCollection Children {get;}
Provides access to the children collection for this object
string Class {get; set;}
Much like the HTML concept of class, a space-separated list of class names which can be used by CSS Selectors to select this node
ReferenceContract Contract {get; set;}
Provides access to the ReferenceContract (which keeps track of runtime changes to an Object Type Reference)
DOMDocument Document {get;}
Provides access to the DOMDocument of which this node is a part.
bool Enabled {get; set;}
When True the effects of this object and its children should be honored in a client, for example a DOMLight should shine, a DOMRenderable should display, etc. Conversely when False, this object should be treated as though it were hidden and it's effects ignored.
long ID {get; set;}
The unique ID of this object in the view. DOM node IDs can change if a node is moved between view documents or removed from a document in which case this property will return zero. DOM node IDs are allocated by the RootDocument in a view
Guid? InstanceIndex {get;}
Used internally by the referencing system
DOMObject InstanceRoot {get;}
Finds the node up the hierarchy that represents the root of this Object Type Reference (assuming this node is part of one, otherwise null)
Guid? InstanceTypeID {get; set;}
The type ID of the next Object Type up the hierarchy in a derived Object Type Reference chain
bool IsInReference {get;}
True if this node is part of a Object Type Reference
bool IsInstanceRoot {get;}
True if this node is the root node in an Object Type Reference
bool IsTemplateRoot {get;}
True if this node represents the root node of an instance of an Object Template
bool IsTopLevelReference {get;}
True if this node is the top-most reference root
bool IsTypeRoot {get; set;}
True if this node represents the root node of an Object Type
Guid MergeID {get; set;}
An ID that makes this object unique within it's container (parent). The MergeID changes whenever the object is re-parented.
bool MergeLocked {get;}
Used by the merge system to prevent change tracking in certain cases
Guid NodeID {get; set;}
Unique ID set on first creation (not sure how this is different than RecordID)
string NodePath {get;}
Gets a path which can be used to locate a specific node in the DOM using the FindNode method
IEnumerable<DOMAttribute> ObjectAttributes {get;}
Gets a list of DOMAttributes on this node
DOMObject Parent {get;}
The parent DOMObject of this node
DOMPropertyCollection Properties {get;}
Provides access to the property collection for this object
DOMProtectionFlags ProtectionFlags {get; set;}
A set of flags representing protections enforced by the server. Delete object (1), Move object (2), Add child (4), Remove child (8), Change object (16) are some of the possible flags. This property can only be set on the server and is used to protect certain objects from accidental operations that could be harmful to the basic DOM structure, like deleting the root instance document for example.
Guid RecordID {get;}
The ID used to uniquely identify an object. RecordIDs are generated when a new DOMObject is created.
DOMDocument RootDocument {get;}
Provides access to the top-most DOMDocument of which this node is a part.
DateTime ServerTime {get;}
Gets the current server time
List<string> SystemPropertyNames {get;}
Returns a list of system property names for this node type
object Tag {get; set;}
A property you can use to associate this object with something in your DOM host (a TreeNode or GameObject for example)
Guid TemplateID {get; set;}
If this node is part of an instaniated Object Template this property will contain the ID of the template
DOMObject TemplateRoot {get;}
Finds the node up the hierarchy that represents the root of this Object Template instantiation (assuming this node is part of one, otherwise null)
bool Temporary {get; set;}
A node marked as Temporary will not be serialized for storage and will not be disturbed during a publish merge. They are considered "runtime nodes" not part of the saved layout or type.
string Title {get; set;}
The title of the object, usually used only for display in a server inspector, but sometimes has special meaning (eg. in DOMTitle, DOMHookpoint, and DOMCurveValue nodes
bool Transient {get; set;}
A transient node is meant to be removed from the DOM immediately after it is received. On the server side, when a node marked Transient is added to the DOM a ChildAdd packet is sent to the client, but the node is never added to the Children collection of the target parent.
Guid TypeID {get; set;}
The ID of the Object Type (stored DOM snippet) that this node is a part of. If the Object Type is a derived reference or this node is part of a reference inside an Object Type this will indicate the first type in which this node was introduced
Guid? TypeIndex {get;}
Used internally by the referencing system
int TypeNodeID {get; set;}
When part of an Object Type this integer ID uniquely identifies the node within the type. Note that if an Object Type contains references those nodes could have conflicting TypeNodeIDs but their TypeID would appear different.
bool TypeReference {get; set;}
True if this node is the root of a type reference (as in, not locally defined, but here as the result of a DOMReference expansion, and will be serialized as a DOMReference)
bool[] TypeReferenceReload {get; set;}
A Dirkasaurus-Rex Boolean Factory
DOMObject TypeRoot {get;}
Finds the node up the hierarchy that represents the root of this object type (assuming this node is part of one, otherwise null)
bool Validated {get; set;}
True if this object has a template ID and that Object Template was found in a container attached to the worldspace in which this view is running.
bool Viewable {get;}
True if the object is both Visible and Validated and if it has a parent, that parent is accessible as well
bool Visible {get; set;}
Marks a node as visible or not visible to connected clients. When toggled, the server sends RemoveNode / AddNode packets, so from a client perspective it's as though the node is added or removed from the DOM. It can be useful to hide nodes that will be used or cloned by scripts. It can be useful to mark a node as not visible before making many changes to it's subtree to reduce network traffic, although BeginUpdate and EndUpdate are better suited for this.

Events

ChildBeforeAdd(EventHandler<DOMUpdateChildAdd>)
Fires just before a child is added to this node or one of its children. You can use this event to prevent a node from being added to the DOM or examine it while it is still an orphaned node
ChildBeforeRemove(EventHandler<DOMUpdateChildRemove>)
Fires just before a child is removed from this node or one of its children. You can use this event to prevent a node from being removed from the DOM or examine it while it's parentage is still intact
Updated(EventHandler<DOMUpdateEventArgs>)
Fires when properties or the hierarchy changes on this node or any of its children

Constructors

DOMObject()
Constructs a new DOMObject with default settings
DOMObject(DOMObject[] children)
Constructs a new DOMObject, adding children at the same time
DOMObject(string title, DOMObject[] children)
Constructs a new DOMObject, setting a title and adding children at the same time

Methods

void AddClass(string className)
Similar to JQuery's AddClass method, this adds one space separated item to the Class property without disturbing the others
void BeginUpdate()
Begins an update, which coalesces many changes to the DOM into a single update. You can add and remove nodes and change properties. WHen you're done, call EndUpdate.
bool CheckChild(DOMObject child)
Called on DOMObject derived types just before a child is added to their Children collection to ensure they are acceptable
bool CheckParent(DOMObject parent)
Called on DOMObject derived types just before they are added to the DOM to ensure their parent is appropriate.
void ClearChildren()
Removes all children from this DOM node
DOMObject Clone()
Gets a deep clone of the current object
bool Contains<T>(T value, DOMSearchLevel applyTo)
Searches the specified object within the specified scope
bool Contains(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
Searches the specified object within the specified scope and matching the specified predicate
bool Contains<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
Searches the specified object within the specified scope and matching the specified predicate and type
T2 ContainsTest<T1, T2>(T1 value, T2 value2)
This is a test
int Count<T>()
Returns a count of all child nodes that match the specified type
int Count<T>(DOMSearchLevel applyTo)
Returns a count of all nodes within the specified scope that match the specified type
int Count<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
Returns a count of all nodes within the specified scope and matching the supplied predicate and type
int Count(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
Returns a count of all nodes within the specified scope and matching the supplied predicate
DOMObject Detach()
Detaches the node from its parent and resets the childrens ID's
void EndUpdate()
Ends an update, sending all accumulated changes to connected clients.
bool Equals(DOMObject first, DOMObject second)
Tests if two DOMObjects are the same object
bool Equals(DOMObject other)
Tests if this DOMObject is the same object as another (compares reference hashcodes)
DOMObject FindNode(string nodepath, Guid? templateID)
Gets the node that matches the object type node path (Example: 40/23)
DOMObject First(DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope
T First<T>(DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope and matching the supplied type
DOMObject First(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope and matching the supplied predicate
T First<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope and matching the supplied predicate and type
DOMObject FirstOrDefault(DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope
T FirstOrDefault<T>(DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope and matching the supplied type
DOMObject FirstOrDefault(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope and matching the supplied predicate
T FirstOrDefault<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
Finds the first DOMObject in the specified scope and matching the supplied predicate and type
void ForEach(Func<DOMObject, bool> predicate, Action<DOMObject> action, DOMSearchLevel applyTo)
Executes the specified action on all nodes withing the specified scope and matching the supplied predicate
void ForEach<T>(Func<T, bool> predicate, Action<T> action, DOMSearchLevel applyTo)
Executes the specified action on all nodes withing the specified scope and matching the supplied predicate and type
TResult GetAttributeValue<TResult>(string attributeName, string propertyName)
Gets the value of the specified attribute if it is defined on this node or the specified property
int GetHashCode(DOMObject obj)
Calls DOMObject.GetHashCode on the specified object
T GetLocalProperty<T>(string key, Func<T> defaultSelector)
Gets the value of a local property of this DOM node
IEnumerable<string> GetPropertiesWithAttribute(string attributeName)
Gets a list of the names of all the properties that have the specified attribute defined on them
bool HasAttribute(string attributeName, string propertyName)
Tests if this node or a specific property has the specified attribute defined on it
bool HasClass(string className)
Similar to JQuery's HasClass method, this checks for the existance of one space separated item on the Class property
bool MatchesSelector(string selector)
Tests if this node matches the specified CSS Selector
void MergeFrom(DOMObject source, bool restore, DOMDiffOperations type)
Preforms a merge form the specified source to this object
IEnumerable<T> OfType<T>(DOMSearchLevel applyTo)
Returns all nodes withing the specified scope and matching the specified type
T ParentOfType<T>()
Searches up the DOM hierarchy looking for a parent of the specified type
DOMObject QuerySelector(string selector)
Returns the first object that matchs the specified CSS Selector. This could be this node, or one of its children.
IEnumerable<DOMObject> QuerySelectorAll(string selector)
Returns all the nodes that match the specified CSS Selector. This could include this node, and anty of its children.
void ReID()
Resets the ID property of this and all child objects using IDs generated by its root document
void RemoveClass(string className)
Similar to JQuery's RemoveClass method, this removes one space separated item to the Class property without disturbing the others
int RemoveLocalProperties(Func<string, bool> predicate)
Removes any local properties, using a predicate function to test the keys
object RemoveLocalProperty(string key)
Removes a single local property by its key
void ResetTypeID(Guid typeID)
Changes the TypeID on this node and all sub-nodes that share the current TypeID. The Template ID of this node is also cleared
void Revalidate(Func<DOMObject, bool> validationCallback)
Used internally by the instance host to validate DOM nodes
void SetLocalProperty(string key, object value)
Sets the value of a local property
void ToggleClass(string className)
Similar to JQuery's ToggleClass method, this toggles (adds or removes) one space separated item on the Class property without disturbing the others
string ToString()
Gets a string represnetation of this DOM Node
bool TryGetLocalProperty<T>(string key, out T result)
IEnumerable<DOMObject> Where(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
Returns all nodes withing the specified scope and matching the specified predicate
IEnumerable<T> Where<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
Returns all nodes withing the specified scope and matching the specified predicate and type