private void Init(Type type) { var attrs = type.GetCustomAttributes <HtmlLocationAttribute>(); foreach (var attr in attrs) { LocationFunc func = (node) => { var nds = node.QuerySelectorAll(attr.JqSelector); if (attr.Index == null) { return(nds.ToList()); } if (nds.Count() < attr.Index.Value) { return(new List <HtmlNode>() { nds[attr.Index.Value] }); } return(new List <HtmlNode>()); }; locationsCache.Add(func); } var pis = type.GetProperties(); foreach (var pi in pis) { propertyMappingCache.Add(pi.Name, pi); var ats = pi.GetCustomAttributes <HtmlDataAttribute>(); foreach (var at in ats) { AddFieldMapping(pi, at.JqSelector, at.Index, at.AttrName); } } }
public void AddLocation(LocationFunc func) { locationsCache.Add(func); }