/// <summary> /// Gets the child page objects. /// If a child page object is a generic type definition that matches with the hint type, this type is returned. /// The hint is necessary since the type parameters cannot be "guessed". /// </summary> /// <typeparam name="TPageObjectChildHint">The hint type for a generic type definition page object child.</typeparam> /// <returns>The child page objects.</returns> public IEnumerable <IPageObject> Children <TPageObjectChildHint>() { List <IPageObject> result = new List <IPageObject>(); foreach (var childPageObject in Locate.ChildTypes(this).Union(RootInternal.DynamicChildren(GetType()))) { Type toAdd; Type hintType = typeof(TPageObjectChildHint); if (!childPageObject.IsGenericTypeDefinition) { toAdd = childPageObject; } else if (hintType.IsGenericType && hintType.GetGenericTypeDefinition() == childPageObject) { // check if the type definition of the page object we are searching for, is the same as the child page object // use the type parameters passed via the type argument toAdd = hintType; } else { continue; } // create and init child page object result.Add(((IUIObjectInternal)Activator.CreateInstance(toAdd)).Init(this) as IPageObject); } return(result); }