From 76812681c74cb137ed1fedee31cfa30284d21a45 Mon Sep 17 00:00:00 2001 From: Enkidu93 Date: Thu, 1 Aug 2024 13:05:58 -0400 Subject: [PATCH] Add constructor --- .../Corpora/ParatextProjectTextUpdaterBase.cs | 17 ++++++++++------- .../ZipParatextProjectTextUpdaterBase.cs | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs b/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs index 7cacc7df..1e08242e 100644 --- a/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs +++ b/src/SIL.Machine/Corpora/ParatextProjectTextUpdaterBase.cs @@ -5,11 +5,16 @@ namespace SIL.Machine.Corpora { public abstract class ParatextProjectTextUpdaterBase { - private readonly ParatextProjectSettingsParserBase _settingsParser; + private readonly ParatextProjectSettings _settings; protected ParatextProjectTextUpdaterBase(ParatextProjectSettingsParserBase settingsParser) { - _settingsParser = settingsParser; + _settings = settingsParser.Parse(); + } + + protected ParatextProjectTextUpdaterBase(ParatextProjectSettings settings) + { + _settings = settings; } public string UpdateUsfm( @@ -20,9 +25,7 @@ public string UpdateUsfm( bool preferExistingText = true ) { - ParatextProjectSettings settings = _settingsParser.Parse(); - - string fileName = settings.GetBookFileName(bookId); + string fileName = _settings.GetBookFileName(bookId); if (!Exists(fileName)) return null; @@ -38,8 +41,8 @@ public string UpdateUsfm( stripAllText, preferExistingText: preferExistingText ); - UsfmParser.Parse(usfm, handler, settings.Stylesheet, settings.Versification); - return handler.GetUsfm(settings.Stylesheet); + UsfmParser.Parse(usfm, handler, _settings.Stylesheet, _settings.Versification); + return handler.GetUsfm(_settings.Stylesheet); } protected abstract bool Exists(string fileName); diff --git a/src/SIL.Machine/Corpora/ZipParatextProjectTextUpdaterBase.cs b/src/SIL.Machine/Corpora/ZipParatextProjectTextUpdaterBase.cs index 9004d421..3cf16a6e 100644 --- a/src/SIL.Machine/Corpora/ZipParatextProjectTextUpdaterBase.cs +++ b/src/SIL.Machine/Corpora/ZipParatextProjectTextUpdaterBase.cs @@ -4,5 +4,8 @@ public abstract class ZipParatextProjectTextUpdaterBase : ParatextProjectTextUpd { protected ZipParatextProjectTextUpdaterBase(ZipParatextProjectSettingsParserBase settingsParser) : base(settingsParser) { } + + protected ZipParatextProjectTextUpdaterBase(ParatextProjectSettings settings) + : base(settings) { } } }