Skip to content

Commit 918014c

Browse files
committed
Add TryParse to ScriptureRef
1 parent c5e7c02 commit 918014c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/SIL.Machine/Corpora/ScriptureRef.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ public static ScriptureRef Parse(string str, ScrVers versification = null)
4343
return new ScriptureRef(new VerseRef(vref, versification ?? ScrVers.English), path);
4444
}
4545

46+
public static bool TryParse(string str, out ScriptureRef scriptureRef, ScrVers versification = null)
47+
{
48+
try
49+
{
50+
scriptureRef = Parse(str, versification);
51+
return true;
52+
}
53+
catch
54+
{
55+
scriptureRef = Empty;
56+
return false;
57+
}
58+
}
59+
4660
public ScriptureRef(VerseRef verseRef = default, IEnumerable<ScriptureElement> path = null)
4761
{
4862
VerseRef = verseRef;

0 commit comments

Comments
 (0)