Skip to content

Commit 9b54fa0

Browse files
committed
Expose CultureInfo to Xml TryGetAttribute
1 parent 813e91b commit 9b54fa0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Noggog.CSharpExt/Extensions/XmlExt.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics.CodeAnalysis;
2+
using System.Globalization;
23
using System.Reflection;
34
using System.Text;
45
using System.Xml.Linq;
@@ -69,7 +70,7 @@ public static bool TryGetAttribute<P>(this XElement node, string str, [MaybeNull
6970
return true;
7071
}
7172

72-
public static bool TryGetAttribute<P>(this XElement node, string str, [MaybeNullWhen(false)] out P val, bool throwException = false)
73+
public static bool TryGetAttribute<P>(this XElement node, string str, [MaybeNullWhen(false)] out P val, bool throwException = false, CultureInfo? culture = null)
7374
{
7475
var ret = TryGetAttribute<P>(node, str, out val, (strVal) =>
7576
{
@@ -90,7 +91,7 @@ public static bool TryGetAttribute<P>(this XElement node, string str, [MaybeNull
9091
}
9192
else
9293
{
93-
return (P)Convert.ChangeType(strVal, t);
94+
return (P)Convert.ChangeType(strVal, t, culture);
9495
}
9596
}
9697
catch (Exception)

0 commit comments

Comments
 (0)