Kanzi 3.9.10
NodeReference< T > Class Template Reference

Create node references. More...

Inheritance diagram for NodeReference< T >:
[legend]
Collaboration diagram for NodeReference< T >:
[legend]

Public Member Functions

 NodeReference (string relativePath)
 Creates a node reference using a relative path.
 
 NodeReference (T targetNode)
 Creates a node reference.
 
T GetTarget (Node context)
 Gets the node to which a relative node reference points.
 
- Public Member Functions inherited from ProjectItemReference< T >
T GetTarget (Node context)
 Gets the node to which a relative node reference points.
 

Additional Inherited Members

- Properties inherited from ProjectItemReference< T >
bool IsAbsoluteReference [get]
 Gets whether a project item reference is an absolute reference.
 

Detailed Description

Create node references.

For example, use a node reference in a message action to set the target item.

Template Parameters
T
Type Constraints
T :class 
T :Node 

Constructor & Destructor Documentation

◆ NodeReference() [1/2]

NodeReference ( string relativePath)
inline

Creates a node reference using a relative path.

Parameters
relativePathRelative path to the node to which you want the reference to point.

Examples

To create a node reference using a relative path:

{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// In the RootPage node create a Page node named Intro.
var introPage = studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Intro"), rootPage);
// Set the Default Subpage property of the RootPage node to the Intro node.
rootPage.Set(Properties.PageHostDefaultSubPage.Name, "Intro");
// In the RootPage node create a Page node named Main.
studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Main"), rootPage);
// In the Intro Page node get the first Page Activated trigger.
introPage.Triggers.First(
trigger => trigger.Get(Properties.TriggerMessageType) == studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.Page.Activated"));
// In the Page Activated trigger create a trigger action, and set:
// * Trigger Action Type to Dispatch Message Action
// * Message Type to Navigate To Page
var navigateToPageAction = pageActivatedTrigger.CreateAction(studio.ActiveProject.TriggerActionTypeLibrary.GetItemByName("Kanzi.DispatchMessageAction"));
navigateToPageAction.DispatchMessageActionMessageType = studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.Page.Navigate");
// Create a node reference using a relative path from the Intro Page node to the Main Page node.
// In the Navigate To Page action set Item to relative path that points from the Intro Page node to the Main Page node.
navigateToPageAction.RoutingTarget = routingTarget;
// In the Navigate To Page action set Delay to 2000 ms.
navigateToPageAction.Delay = 2000;
}

◆ NodeReference() [2/2]

NodeReference ( T targetNode)
inline

Creates a node reference.

Parameters
targetNodeThe node to which you want the reference to point.

Examples

To create a node reference:

{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// In the RootPage node create a Page node named Intro.
var introPage = studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Intro"), rootPage);
// Set the Default Subpage property of the RootPage node to the Intro node.
rootPage.Set(Properties.PageHostDefaultSubPage.Name, "Intro");
// In the RootPage node create a Page node named Main.
var mainPage = studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Main"), rootPage);
// In the Intro Page node get the first Page Activated trigger.
introPage.Triggers.First(
trigger => trigger.Get(Properties.TriggerMessageType) == studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.Page.Activated"));
// In the Page Activated trigger create a trigger action, and set:
// * Trigger Action Type to Dispatch Message Action
// * Message Type to Navigate To Page
var navigateToPageAction = pageActivatedTrigger.CreateAction(studio.ActiveProject.TriggerActionTypeLibrary.GetItemByName("Kanzi.DispatchMessageAction"));
navigateToPageAction.DispatchMessageActionMessageType = studio.ActiveProject.MessageTypeLibrary.GetItemByName("Message.Page.Navigate");
// Create a node reference that points to the Main Page node.
// In the Navigate To Page action set Item to absolute path that points to the Main Page node.
navigateToPageAction.RoutingTarget = routingTarget;
// In the Navigate To Page action set Delay to 2000 ms.
navigateToPageAction.Delay = 2000;
}

Member Function Documentation

◆ GetTarget()

T GetTarget ( Node context)
inline

Gets the node to which a relative node reference points.

Parameters
contextThe node that you use to resolve the relative path to the target node.
Returns
The node to which a relative node reference points.

Examples

To get the node to which a relative node reference points:

{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.ActiveProject.GetProjectItem("Screens/Screen/RootPage");
// In the RootPage node create a Page node named Intro.
var introPage = studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Intro"), rootPage);
// In the RootPage node create a Page node named Main.
studio.ActiveProject.CreateProjectItem<Page>(rootPage.GenerateUniqueChildName("Main"), rootPage);
// Create a node reference using a relative path from the Intro Page node to the Main Page node.
// Get the target node of the node reference that you created.
// Use the Intro Page node as the context for resolving the relative path to the Main Page node.
// Print the absolute path to the target node to the Kanzi Studio Log window.
studio.Log(target.Path);
}