Skip to content

Commit

Permalink
fix with adding newline to set property
Browse files Browse the repository at this point in the history
  • Loading branch information
rwecho committed Jul 25, 2023
1 parent aa54c1b commit 0b8507e
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions src/HtmlAgilityPack.Shared/HtmlNode.Encapsulator.cs
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -30,7 +30,7 @@ public partial class HtmlNode
/// <exception cref="XPathException">Why it's thrown.</exception>
/// <exception cref="NodeNotFoundException">Why it's thrown.</exception>
/// <exception cref="NodeAttributeNotFoundException">Why it's thrown.</exception>
/// <exception cref="FormatException">Why it's thrown.</exception>
/// <exception cref="FormatException">Why it's thrown.</exception>
/// <exception cref="Exception">Why it's thrown.</exception>
public T GetEncapsulatedData<T>()
{
Expand All @@ -51,7 +51,7 @@ public T GetEncapsulatedData<T>()
/// <exception cref="XPathException">Why it's thrown.</exception>
/// <exception cref="NodeNotFoundException">Why it's thrown.</exception>
/// <exception cref="NodeAttributeNotFoundException">Why it's thrown.</exception>
/// <exception cref="FormatException">Why it's thrown.</exception>
/// <exception cref="FormatException">Why it's thrown.</exception>
/// <exception cref="Exception">Why it's thrown.</exception>
public T GetEncapsulatedData<T>(HtmlDocument htmlDocument)
{
Expand All @@ -73,7 +73,7 @@ public T GetEncapsulatedData<T>(HtmlDocument htmlDocument)
/// <exception cref="XPathException">Why it's thrown.</exception>
/// <exception cref="NodeNotFoundException">Why it's thrown.</exception>
/// <exception cref="NodeAttributeNotFoundException">Why it's thrown.</exception>
/// <exception cref="FormatException">Why it's thrown.</exception>
/// <exception cref="FormatException">Why it's thrown.</exception>
/// <exception cref="Exception">Why it's thrown.</exception>
public object GetEncapsulatedData(Type targetType, HtmlDocument htmlDocument = null)
{
Expand Down Expand Up @@ -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,
Expand All @@ -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<string>(htmlNode, xPathAttribute);
}
Expand Down Expand Up @@ -386,9 +386,6 @@ public object GetEncapsulatedData(Type targetType, HtmlDocument htmlDocument = n
}
#endregion targetObject_NOTDefined_XPath
}



}


Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -734,7 +729,7 @@ internal static int CountOfIEnumerable<T>(this IEnumerable<T> source)
counter++;
}
return counter;
}
}

/// <summary>
/// Return html part of <see cref="HtmlNode"/> based on <see cref="ReturnType"/>
Expand All @@ -757,8 +752,6 @@ internal static string GetHtmlForEncapsulation(HtmlNode node, ReturnType returnT
throw new IndexOutOfRangeException("Unhandled ReturnType : " + returnType.ToString());
};
}


}


Expand All @@ -768,7 +761,7 @@ internal static string GetHtmlForEncapsulation(HtmlNode node, ReturnType returnT
public enum ReturnType
{
/// <summary>
/// The text between the start and end tags of the object.
/// The text between the start and end tags of the object.
/// </summary>
InnerText,

Expand Down Expand Up @@ -819,7 +812,8 @@ public sealed class XPathAttribute : Attribute
/// </summary>
public ReturnType NodeReturnType
{
get => _nodeReturnType; set
get => _nodeReturnType;
set
{
_nodeReturnType = value;
IsNodeReturnTypeExplicitlySet = true;
Expand Down Expand Up @@ -892,18 +886,18 @@ public sealed class SkipNodeNotFoundAttribute : Attribute
public class NodeNotFoundException : Exception
{
/// <summary>
///
///
/// </summary>
public NodeNotFoundException() { }

/// <summary>
///
///
/// </summary>
/// <param name="message"></param>
public NodeNotFoundException(string message) : base(message) { }

/// <summary>
///
///
/// </summary>
/// <param name="message"></param>
/// <param name="inner"></param>
Expand All @@ -917,18 +911,18 @@ public NodeNotFoundException(string message, Exception inner) : base(message, in
public class NodeAttributeNotFoundException : Exception
{
/// <summary>
///
///
/// </summary>
public NodeAttributeNotFoundException() { }

/// <summary>
///
///
/// </summary>
/// <param name="message"></param>
public NodeAttributeNotFoundException(string message) : base(message) { }

/// <summary>
///
///
/// </summary>
/// <param name="message"></param>
/// <param name="inner"></param>
Expand All @@ -943,18 +937,18 @@ public class MissingXPathException : Exception
{

/// <summary>
///
///
/// </summary>
public MissingXPathException() { }

/// <summary>
///
///
/// </summary>
/// <param name="message"></param>
public MissingXPathException(string message) : base(message) { }

/// <summary>
///
///
/// </summary>
/// <param name="message"></param>
/// <param name="inner"></param>
Expand All @@ -963,7 +957,7 @@ public MissingXPathException(string message, Exception inner) : base(message, in

}

#if FX20
#if FX20
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method |
Expand Down

0 comments on commit 0b8507e

Please sign in to comment.