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 22: Line 22:
  
 
:{{CSharp|Guid? BaseTypeID {get; set;} }}
 
:{{CSharp|Guid? BaseTypeID {get; set;} }}
 +
::
 +
::The type ID of the root [[Object Type]] in a derived [[Object Type Reference]] chain
  
 
:{{CSharp|DOMObjectCollection Children {get;} }}
 
:{{CSharp|DOMObjectCollection Children {get;} }}
Line 32: Line 34:
  
 
:{{CSharp|ReferenceContract Contract {get; set;} }}
 
:{{CSharp|ReferenceContract Contract {get; set;} }}
 +
::
 +
::Provides access to the ReferenceContract (which keeps track of runtime changes to an [[Object Type Reference]])
  
 
:{{CSharp|DOMDocument Document {get;} }}
 
:{{CSharp|DOMDocument Document {get;} }}
Line 46: Line 50:
  
 
:{{CSharp|Guid? InstanceIndex {get;} }}
 
:{{CSharp|Guid? InstanceIndex {get;} }}
 +
::
 +
::Used internally by the referencing system
  
 
:{{CSharp|DOMObject InstanceRoot {get;} }}
 
:{{CSharp|DOMObject InstanceRoot {get;} }}
Line 52: Line 58:
  
 
:{{CSharp|Guid? InstanceTypeID {get; set;} }}
 
:{{CSharp|Guid? InstanceTypeID {get; set;} }}
 +
::
 +
::The type ID of the next [[Object Type]] up the hierarchy in a derived [[Object Type Reference]] chain
  
 
:{{CSharp|bool IsInReference {get;} }}
 
:{{CSharp|bool IsInReference {get;} }}
Line 58: Line 66:
  
 
:{{CSharp|bool IsInstanceRoot {get;} }}
 
:{{CSharp|bool IsInstanceRoot {get;} }}
 +
::
 +
::True if this node is the root node in an [[Object Type Reference]]
  
 
:{{CSharp|bool IsTemplateRoot {get;} }}
 
:{{CSharp|bool IsTemplateRoot {get;} }}
Line 76: Line 86:
  
 
:{{CSharp|bool MergeLocked {get;} }}
 
:{{CSharp|bool MergeLocked {get;} }}
 +
::
 +
::Used by the merge system to prevent change tracking in certain cases
  
 
:{{CSharp|Guid NodeID {get; set;} }}
 
:{{CSharp|Guid NodeID {get; set;} }}
 +
::
 +
::Unique ID set on first creation (not sure how this is different than RecordID)
  
 
:{{CSharp|string NodePath {get;} }}
 
:{{CSharp|string NodePath {get;} }}
Line 144: Line 158:
  
 
:{{CSharp|Guid? TypeIndex {get;} }}
 
:{{CSharp|Guid? TypeIndex {get;} }}
 +
::
 +
::Used internally by the referencing system
  
 
:{{CSharp|int TypeNodeID {get; set;} }}
 
:{{CSharp|int TypeNodeID {get; set;} }}
Line 195: Line 211:
 
===Methods===
 
===Methods===
 
:{{CSharp|void AddClass(string className)}}
 
:{{CSharp|void AddClass(string className)}}
 +
::
 +
::Similar to JQuery's AddClass method, this adds one space separated item to the Class property without disturbing the others
  
 
:{{CSharp|void BeginMergeUpdate()}}
 
:{{CSharp|void BeginMergeUpdate()}}
Line 283: Line 301:
  
 
:{{CSharp|bool HasClass(string className)}}
 
:{{CSharp|bool HasClass(string className)}}
 +
::
 +
::Similar to JQuery's HasClass method, this checks for the existance of one space separated item on the Class property
  
 
:{{CSharp|bool MatchesSelector(string selector)}}
 
:{{CSharp|bool MatchesSelector(string selector)}}
 +
::
 +
::Tests if this node matches the specified [[CSS Selectors|CSS Selector]]
  
 
:{{CSharp|void MergeFrom(DOMObject source, bool restore, DOMDiffOperations type)}}
 
:{{CSharp|void MergeFrom(DOMObject source, bool restore, DOMDiffOperations type)}}
Line 295: Line 317:
  
 
:{{CSharp|DOMObject QuerySelector(string selector)}}
 
:{{CSharp|DOMObject QuerySelector(string selector)}}
 +
::
 +
::Returns the first object that matchs the specified [[CSS Selectors|CSS Selector]]. This could be this node, or one of its children.
  
 
:{{CSharp|IEnumerable<DOMObject> QuerySelectorAll(string selector)}}
 
:{{CSharp|IEnumerable<DOMObject> QuerySelectorAll(string selector)}}
 +
::
 +
::Returns all the nodes that match the specified [[CSS Selectors|CSS Selector]]. This could include this node, and anty of its children.
  
 
:{{CSharp|void ReID()}}
 
:{{CSharp|void ReID()}}
  
 
:{{CSharp|void RemoveClass(string className)}}
 
:{{CSharp|void RemoveClass(string className)}}
 +
::
 +
::Similar to JQuery's RemoveClass method, this removes one space separated item to the Class property without disturbing the others
  
 
:{{CSharp|int RemoveLocalProperties(Func<string, bool> keySelector)}}
 
:{{CSharp|int RemoveLocalProperties(Func<string, bool> keySelector)}}
Line 312: Line 340:
 
:{{CSharp|void SetLocalProperty(string key, object value)}}
 
:{{CSharp|void SetLocalProperty(string key, object value)}}
 
:{{CSharp|void ToggleClass(string className)}}
 
:{{CSharp|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
  
 
:{{CSharp|string ToString()}}
 
:{{CSharp|string ToString()}}

Revision as of 13:52, 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>)
ChildBeforeRemove(EventHandler<DOMUpdateChildRemove>)
Updated(EventHandler<DOMUpdateEventArgs>)

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 BeginMergeUpdate()
void BeginUpdate()
bool CheckChild(DOMObject child)
bool CheckParent(DOMObject parent)
void ClearChildren()
DOMObject Clone()
Gets a deep clone of the current object
bool Contains<T>(T value, DOMSearchLevel applyTo)
bool Contains(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
bool Contains<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
bool ContainsTypeReference(Guid typeID)
int Count<T>()
int Count<T>(DOMSearchLevel applyTo)
int Count<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
int Count(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
DOMObject Detach()
Detaches the node from its parent and resets the childrens ID's
bool DiscoverTemplate(Guid templateID)
bool DiscoverType(Guid typeID)
void EndMergeUpdate()
void EndUpdate()
bool Equals(DOMObject x, DOMObject y)
bool Equals(DOMObject other)
DOMObject FindNode(string nodepath, Guid? templateID)
Gets the node that matches the object type node path (Example: 40/23)
DOMObject First(DOMSearchLevel applyTo)
T First<T>(DOMSearchLevel applyTo)
DOMObject First(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
T First<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
DOMObject FirstOrDefault(DOMSearchLevel applyTo)
T FirstOrDefault<T>(DOMSearchLevel applyTo)
DOMObject FirstOrDefault(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
T FirstOrDefault<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)
void ForEach(Func<DOMObject, bool> predicate, Action<DOMObject> action, DOMSearchLevel applyTo)
void ForEach<T>(Func<T, bool> predicate, Action<T> action, DOMSearchLevel applyTo)
IEnumerable<KeyValuePair<Guid, DOMObject>> GetAttributeKeys()
TResult GetAttributeValue<TResult>(string attributeName, string propertyName)
int GetHashCode(DOMObject obj)
T GetLocalProperty<T>(string key, Func<T> defaultSelector)
Guid? GetNodeIndex(DOMObject baseNode)
Guid GetNodeIndex2(DOMObject baseNode, int depth)
IEnumerable<string> GetPropertiesWithAttribute(string attributeName)
bool HasAttribute(string attributeName, string propertyName)
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)
void MergeFromWithTracking(DOMObject source, bool restore)
IEnumerable<T> OfType<T>(DOMSearchLevel applyTo)
T ParentOfType<T>()
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()
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> keySelector)
object RemoveLocalProperty(string key)
void ResetTypeID(Guid typeID)
void Revalidate(Func<DOMObject, bool> validationCallback)
void SetLocalProperty(string key, object value)
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()
bool TryGetLocalProperty<T>(string key, out T result)
IEnumerable<DOMObject> Where(Func<DOMObject, bool> predicate, DOMSearchLevel applyTo)
IEnumerable<T> Where<T>(Func<T, bool> predicate, DOMSearchLevel applyTo)