internal static Element GetTypedElement(DomContainer domContainer, IHTMLElement element) { Assembly assembly = Assembly.Load("ItiN"); Element returnElement = new ElementsContainer(domContainer, element); foreach (Type type in assembly.GetTypes()) { if (type.IsSubclassOf(typeof(Element))) { PropertyInfo property = type.GetProperty("ElementTags"); if (property != null) { ArrayList elementTags = (ArrayList)property.GetValue(type, null); if (ElementTag.IsValidElement(element, elementTags)) { ConstructorInfo constructor = type.GetConstructor(new Type[] { typeof(Element) }); if (constructor != null) { returnElement = (Element)constructor.Invoke(new object[] { returnElement }); break; } } } } } return(returnElement); }
/// <summary> /// This constructor is mainly used from within WatiN. /// </summary> /// <param name="element">The element.</param> /// <param name="elementTags">The element tags the element should match with.</param> public Element(Element element, ArrayList elementTags) { if (ElementTag.IsValidElement(element.htmlElement, elementTags)) { init(element.domContainer, element.element, element.elementFinder); } else { throw new ArgumentException(String.Format("Expected element {0}", ElementFinder.GetExceptionMessage(elementTags)), "element"); } }