Difference between revisions of "DOMObject"
From Virtual World Web Wiki
(Documentation for the DOMObject class) |
(Documentation for the DOMObject class) |
||
Line 46: | Line 46: | ||
:{{CSharp|HierarchyResolverDelegate HierarchyResolver {get; set;} }} | :{{CSharp|HierarchyResolverDelegate HierarchyResolver {get; set;} }} | ||
+ | |||
+ | :{{CSharp|bool HighLoadPriority {get; set;} }} | ||
+ | :: | ||
+ | ::High Load Priority nodes will be included in the list of things that need to be loaded before the scene will be ready to display. | ||
:{{CSharp|long ID {get; set;} }} | :{{CSharp|long ID {get; set;} }} |
Revision as of 13:28, 15 August 2018
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
- 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)
- bool DebuggingEnabled {get; set;}
- When True, the DOM will output much more debugging noise
- 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.
- HierarchyResolverDelegate HierarchyResolver {get; set;}
- bool HighLoadPriority {get; set;}
- High Load Priority nodes will be included in the list of things that need to be loaded before the scene will be ready to display.
- 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 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 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)
- IEnumerable<DOMAttribute> ObjectAttributes {get;}
- Gets a list of DOMAttributes on this node
- Guid? ObjectTypeID {get;}
- The authoritive "Real" object type ID that this node is a part of
- Guid? OriginalInstanceID {get; set;}
- When this node is an embedded reference, this is a recording of our original instance ID, and will be restored if we are removed (un-embedded) from our parent referebce.
- DOMObject Parent {get;}
- The parent DOMObject of this node
- Guid? ParentInstanceID {get; set;}
- When this node is an embedded reference, this is the instance ID of the next parent reference up the chain
- 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.
- 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
- DOMNodeStorage Storage {get; set;}
- 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
- DOMObject Top {get;}
- Returns the topmost DOM node in this hierarchy
- 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)
- 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)
- Guid? UnboundReferenceID {get; set;}
- When this node was a reference and was UnBound, or if it was instantiated directly from a type (rather than as a reference to a type), this value will be set with the ID of the original Object Type
- 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
- ChildAfterAdd(EventHandler<DOMUpdateChildAdd>)
- Fires just after a child was added to this node or one of its children. You can use this event to cleanup
- 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
- NodeEvent(EventHandler<DOMUpdateNodeEvent>)
- Fires when a node event is received
- 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 AddListenerAllow(DOMListener listener)
- Adds a listener to the allow list. If there is no allow list, one will be created, causing all other listeners to see the node dissapear
- void AddListenerDeny(DOMListener listener)
- Adds a listener to the deny list. This user will see the node dissapear
- void AddListenerWritable(DOMListener listener)
- Adds a listener to this node's writable list. Calls to IsListenerWritable at this node or its children will return true for this listener
- DOMObject ChangeType(DOMObject node, Type type, bool swapInPlace = true)
- Changes the type of this node to another node type (in place or by clone) if possible
- 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
- 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 CreateInstance(Type type)
- Creates an instance of the specified DOMObject type
- bool DiscoverTemplate(Guid templateID)
- Used by Curiosity. This is sillyish
- bool DiscoverType(Guid typeID)
- Used by Curiosity. This is sillyish
- void EmptyListenerAllowList()
- Initializes an empty allow list, or clears an existing one. No listener will be able to see this node after this call (similar to Visible=false)
- 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)
- void FireEvent(string name, string payload, DOMListener[] allowed = NULL, DOMListener[] denied = NULL, Guid? sender = NULL, bool track = true)
- Fires a DOM Event which is a message, with a name and payload, that can be processed by connected clients
- void FireEvent<T>(T instance, DOMListener[] allowed = NULL, DOMListener[] denied = NULL, Guid? sender = NULL, bool track = true)
- Fires a DOM Event which is a message, with a name and payload, that can be processed by connected clients. This version takes an attributed type-safe payload object
- 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 within the specified scope and matching the supplied predicate and type
- TResult GetAttributeValue<TResult>(string attributeName, string propertyName = NULL)
- 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 = NULL)
- 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 = NULL)
- 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 HasLocalProperty(string key)
- Tests if this DOMObject has a local property with the specified key
- bool IsListenerAllowed(DOMListener listener)
- Determines if a given DOMListener is allowed to see updates from this node and its children
- bool IsListenerWritable(DOMListener listener)
- Tests if a given listener has been granted write privilages at this node or one of its parents
- bool MatchesSelector(string selector)
- Tests if this node matches the specified CSS Selector
- void MergeFrom(DOMObject source, bool restore = false, bool applyTo = true, DOMDiffOperation type = DOMDiffOperation.Merge)
- 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 RefreshResource(Guid resourceItemID)
- 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
- void RemoveListenerAllow(DOMListener listener)
- Removes a listener from the allow list. That listener will see this node disappear. If you want everyone to be able to see the node again, use RemoveListenerAllowList.
- void RemoveListenerAllowList()
- Removes the entire allow list. Doing this makes this node visible to everyone again. If you wish to have an allow list, but an empty one, call EmptyListenerAllowList
- void RemoveListenerDeny(DOMListener listener)
- Removes a listener from the deny list. That listener will see this node reappear.
- void RemoveListenerDenyList()
- Removes the entire deny list. All listeners on this list will see this node reappear.
- void RemoveListenerWritable(DOMListener listener)
- Removes a listener from this node's writable list. Calls to IsListenerWritable at this node or its children will return false for this listener
- 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, bool? resetTemplateID = NULL)
- 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
- int SortCompare(DOMObject other)
- Compares this node with another node of the same type for display sorting purposes
- 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