Kanzi  3.9.6
Kanzi Studio API
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. More...
 
 NodeReference (T targetNode)
 Creates a node reference. More...
 
GetTarget (Node context)
 Gets the node to which a relative node reference points. More...
 
- Public Member Functions inherited from ProjectItemReference< T >
GetTarget (Node context)
 Gets the node to which a relative node reference points. More...
 

Additional Inherited Members

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

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:

public void Execute(PluginCommandParameter parameter)
{
// 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.
var pageActivatedTrigger =
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.
ProjectItemReference<ExportedPropertyContainerItem> routingTarget = new NodeReference<Page>("../Main");
// 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 ( targetNode)
inline

Creates a node reference.

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

Examples

To create a node reference:

public void Execute(PluginCommandParameter parameter)
{
// 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.
var pageActivatedTrigger =
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.
ProjectItemReference<ExportedPropertyContainerItem> routingTarget = new NodeReference<Page>(mainPage);
// 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:

public void Execute(PluginCommandParameter parameter)
{
// 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.
ProjectItemReference<ExportedPropertyContainerItem> routingTarget = new NodeReference<Page>("../Main");
// 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.
var target = routingTarget.GetTarget(introPage);
// Print the absolute path to the target node to the Kanzi Studio Log window.
studio.Log(target.Path);
}