public static bool TryGetProperty <T>(this HtmlControl control, string propertyName, Func <string, T> transformFunc, out T propertyValue) { string propertyString; if (!control.TryGetProperty(propertyName, out propertyString)) { propertyValue = default(T); return(false); } try { propertyValue = transformFunc(propertyString); } catch { propertyValue = default(T); return(false); } return(true); }
public static bool TryGetProperty(this HtmlControl control, string propertyName, out string propertyValue) { return(control.TryGetProperty <string>(propertyName, out propertyValue)); }
// TODO: ensure that properties without values return true (eg, <details open>) public static bool HasProperty(this HtmlControl control, string propertyName) { object obj; return(control.TryGetProperty(propertyName, out obj)); }