From 0b8507ee6a211bc57db7484d8a19c5b4e0d2c0f5 Mon Sep 17 00:00:00 2001 From: rwecho Date: Tue, 25 Jul 2023 23:40:13 +0800 Subject: [PATCH] fix with adding newline to set property --- .../HtmlNode.Encapsulator.cs | 50 ++++++++----------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/src/HtmlAgilityPack.Shared/HtmlNode.Encapsulator.cs b/src/HtmlAgilityPack.Shared/HtmlNode.Encapsulator.cs index e563a223..af4e87bd 100644 --- a/src/HtmlAgilityPack.Shared/HtmlNode.Encapsulator.cs +++ b/src/HtmlAgilityPack.Shared/HtmlNode.Encapsulator.cs @@ -1,9 +1,9 @@ -// Description: Html Agility Pack - HTML Parsers, selectors, traversors, manupulators. +// Description: Html Agility Pack - HTML Parsers, selectors, traversors, manupulators. // Website & Documentation: http://html-agility-pack.net // Forum & Issues: https://github.com/zzzprojects/html-agility-pack // License: https://github.com/zzzprojects/html-agility-pack/blob/master/LICENSE // More projects: http://www.zzzprojects.com/ -// Copyright © ZZZ Projects Inc. 2014 - 2017. All rights reserved. +// Copyright © ZZZ Projects Inc. 2014 - 2017. All rights reserved. #if !METRO && !NETSTANDARD1_3 @@ -30,7 +30,7 @@ public partial class HtmlNode /// Why it's thrown. /// Why it's thrown. /// Why it's thrown. - /// Why it's thrown. + /// Why it's thrown. /// Why it's thrown. public T GetEncapsulatedData() { @@ -51,7 +51,7 @@ public T GetEncapsulatedData() /// Why it's thrown. /// Why it's thrown. /// Why it's thrown. - /// Why it's thrown. + /// Why it's thrown. /// Why it's thrown. public T GetEncapsulatedData(HtmlDocument htmlDocument) { @@ -73,7 +73,7 @@ public T GetEncapsulatedData(HtmlDocument htmlDocument) /// Why it's thrown. /// Why it's thrown. /// Why it's thrown. - /// Why it's thrown. + /// Why it's thrown. /// Why it's thrown. public object GetEncapsulatedData(Type targetType, HtmlDocument htmlDocument = null) { @@ -176,7 +176,7 @@ public object GetEncapsulatedData(Type targetType, HtmlDocument htmlDocument = n // Property is None-IEnumerable HasXPath-user-defined class if (propertyInfo.PropertyType.IsDefinedAttribute(typeof(HasXPathAttribute)) == true) { - HtmlDocument innerHtmlDocument = new HtmlDocument(); + HtmlDocument innerHtmlDocument = new HtmlDocument(); innerHtmlDocument.LoadHtml(Tools.GetHtmlForEncapsulation( htmlNode, @@ -195,7 +195,7 @@ public object GetEncapsulatedData(Type targetType, HtmlDocument htmlDocument = n { string result = string.Empty; - if (xPathAttribute.AttributeName == null) // It target value of HTMLTag + if (xPathAttribute.AttributeName == null) // It target value of HTMLTag { result = Tools.GetNodeValueBasedOnXPathReturnType(htmlNode, xPathAttribute); } @@ -386,9 +386,6 @@ public object GetEncapsulatedData(Type targetType, HtmlDocument htmlDocument = n } #endregion targetObject_NOTDefined_XPath } - - - } @@ -632,12 +629,10 @@ internal static IList GetNodesValuesBasedOnXPathReturnType(HtmlNodeCollection ht IList result = listGenericType.CreateIListOfType(); - foreach (HtmlNode node in htmlNodeCollection) { - result.Add(Convert.ChangeType(GetHtmlForEncapsulation(node, xPathAttribute.NodeReturnType), listGenericType)); + result.Add(Convert.ChangeType(GetHtmlForEncapsulation(node, xPathAttribute.NodeReturnType), listGenericType)); } - return result; } @@ -734,7 +729,7 @@ internal static int CountOfIEnumerable(this IEnumerable source) counter++; } return counter; - } + } /// /// Return html part of based on @@ -757,8 +752,6 @@ internal static string GetHtmlForEncapsulation(HtmlNode node, ReturnType returnT throw new IndexOutOfRangeException("Unhandled ReturnType : " + returnType.ToString()); }; } - - } @@ -768,7 +761,7 @@ internal static string GetHtmlForEncapsulation(HtmlNode node, ReturnType returnT public enum ReturnType { /// - /// The text between the start and end tags of the object. + /// The text between the start and end tags of the object. /// InnerText, @@ -819,7 +812,8 @@ public sealed class XPathAttribute : Attribute /// public ReturnType NodeReturnType { - get => _nodeReturnType; set + get => _nodeReturnType; + set { _nodeReturnType = value; IsNodeReturnTypeExplicitlySet = true; @@ -892,18 +886,18 @@ public sealed class SkipNodeNotFoundAttribute : Attribute public class NodeNotFoundException : Exception { /// - /// + /// /// public NodeNotFoundException() { } /// - /// + /// /// /// public NodeNotFoundException(string message) : base(message) { } /// - /// + /// /// /// /// @@ -917,18 +911,18 @@ public NodeNotFoundException(string message, Exception inner) : base(message, in public class NodeAttributeNotFoundException : Exception { /// - /// + /// /// public NodeAttributeNotFoundException() { } /// - /// + /// /// /// public NodeAttributeNotFoundException(string message) : base(message) { } /// - /// + /// /// /// /// @@ -943,18 +937,18 @@ public class MissingXPathException : Exception { /// - /// + /// /// public MissingXPathException() { } /// - /// + /// /// /// public MissingXPathException(string message) : base(message) { } /// - /// + /// /// /// /// @@ -963,7 +957,7 @@ public MissingXPathException(string message, Exception inner) : base(message, in } -#if FX20 +#if FX20 namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Method |