Forum Discussion
kalldrexx
15 years agoContributor
If anyone is interested, here is the code I worked up that (so far) seems to work pretty well.
/// <summary>
/// Checks if a child object exists and retrieves that child's alias mapping
/// </summary>
/// <param name="parent">Parent object</param>
/// <param name="childName">Name of the child VCLObject</param>
/// <param name="timeout">Maximum amount of time (in milliseconds) to wait for the child to exist</param>
/// <returns>Alias object for the VCLObject</returns>
public static var GetVCLChildAsAlias(var parent, string childName, int timeout)
{
// Make sure the parent exists
if (parent == new var(null) || !parent["Exists"])
return new var();
var child = parent["WaitVCLObject"](childName, timeout);
// Make sure the child exists
if (!child["Exists"])
return new var();
// Get the mapped name and make sure it's a valid alias
string[] mappedName = ((string)child["MappedName"]).ToString().Split('.');
if (mappedName.Length < 2 || mappedName[0] != "Aliases")
return new var();
// Loop through all the alias names and create the real alias object
var aliasedChild = Aliases;
for (int x = 1; x < mappedName.Length; x++)
{
// Build the alias object. This assumes that all parent aliases actually exist
// if the aliased parents do not exist, this will cause TC to stall waiting for the object
aliasedChild = aliasedChild[mappedName];
}
return aliasedChild;
}
Related Content
- 8 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 7 days ago