Exemplo n.º 1
0
        private void LoadContent(object obj, HtmlNode objNode)
        {
            var  objType     = obj.GetType();
            bool ignoreBlank = IgnoreBlankAttribute.GetAttribute(objType).Ignore;

            var childNodes = GetContentNodes(objNode, ignoreBlank);

            if (childNodes.Count == 0)
            {
                return;
            }

            if (TrySetList(obj, childNodes, obj))
            {
                return;
            }
            if (TrySetDictionary(obj, childNodes, obj))
            {
                return;
            }


            //设置内容属性
            var propertyInfo = GetContentProperty(obj);

            if (propertyInfo == null)
            {
                return;
            }

            bool propertyIgnorBlank = IgnoreBlankAttribute.GetAttribute(propertyInfo).Ignore;

            if (ignoreBlank != propertyIgnorBlank)
            {
                childNodes = GetContentNodes(objNode, propertyIgnorBlank);
            }

            SetPropertyValue(obj, propertyInfo, childNodes);
        }
Exemplo n.º 2
0
        internal static IList <HtmlNode> GetPropertyNodes(PropertyInfo propertyInfo, HtmlNode ownerNode)
        {
            bool propertyIgnorBlank = IgnoreBlankAttribute.GetAttribute(propertyInfo).Ignore;

            return(GetContentNodes(ownerNode, propertyIgnorBlank));
        }